title: Launch Setting activity then create a dialogue
body: <p>In my app I'd like to send the user to the device setting then create a dialogue asking him to enable something. the problem is the dialogue is always created in my app not the setting activity. <a href="https://i.stack.imgur.com/Gure0.png" rel="nofollow noreferrer">I'm trying to make it look like this.</a></p>
  
  <p>launch setting activity:</p>
  
  <pre><code>Intent overLay = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
  startActivity(overLay);
  </code></pre>
  
  <p>and creating a dialogue:</p>
  
  <pre><code>AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
  alertDialog.setTitle("Alert");
  alertDialog.setMessage("Alert message to be shown");
  alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK",
  new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int which) {
  
  dialog.dismiss();
  }
  });
  alertDialog.show();
  </code></pre>
  
  <p>I've already tried using a new thread but it didn't work. the only thing that kind of works is a toast but not a dialogue.</p>