I'm triggering an AlertDialog from my MainActivity and it works fine like this:
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();
}
});
}
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.
How can I show this AlertDialog always on top?
Note: this AlertDialog is triggered by a push notification listener on my MainActivity, not with a click listener.