title: Android AlertDialog always on top
body: <p>I'm triggering an AlertDialog from my MainActivity and it works fine like this: </p>
  
  <pre><code>public void showCustomAlert(String text){
  
      final String alertText = text;
  
      runOnUiThread(new Runnable() {
          @Override
          public void run() {
              AlertDialog.Builder myDialogBox = new AlertDialog.Builder(mContext);
              myDialogBox.setTitle("Alert");
              myDialogBox.setMessage(alertText);
              myDialogBox.setCancelable(false);
              myDialogBox.setPositiveButton("OK", new DialogInterface.OnClickListener(){
  
                    public void onClick(DialogInterface dialog, int whichButton) {
                           dialog.dismiss();
                    }
  
              });
              myDialogBox.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
              {
                    public void onClick(DialogInterface dialog, int which) {
                           dialog.dismiss();
                    }
              });
              AlertDialog alertDialog = myDialogBox.create();
              alertDialog.show();
         }
      });
  }
  </code></pre>
  
  <p>The problem arises when I open another activity on top of MainActivity and trigger the AlertBox again: it get's behind that activity. When I close the activity, there it is: the AlertDialog is showing.</p>
  
  <p>How can I show this AlertDialog always on top?</p>
  
  <p>Note: this AlertDialog is triggered by a push notification listener on my MainActivity, not with a click listener.</p>