For permission android.permission.SYSTEM_ALERT_WINDOW on Android Marshmallow (6.0) I use the following code:
public class GeneralActivity extends Activity { public final static int ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE = -1010101; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context Context = getBaseContext(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!Settings.canDrawOverlays(Context)) { View APIM = getLayoutInflater().inflate(R.layout.apim, null); setContentView(APIM); Button ALLOW_BUTTON = (Button) findViewById(R.id.allow_button_apim); View.OnClickListener ALLOW_BUTTON_ACTION = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())); startActivityForResult(intent, ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE); } }; ALLOW_BUTTON.setOnClickListener(ALLOW_BUTTON_ACTION); } } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d("CALLED", "OnActivity Result"); } } When the button is pressed, a dialogue really opens in which I give the application rights and press the "back" button and this brings me back to the application, but nothing has entered the onActivityResult.