I have tried out everything I know and can find, but still I cannot get my alert dialog to show as a TYPE_SYSTEM_ALERT. It shows on my app when I open it, but it does not pop up if my app is not on front.
I've got:
final AlertDialog.Builder d = new AlertDialog.Builder(this);
d.setTitle("App name");
d.setMessage("Message");
d.setPositiveButton("OK", null);
d.setIcon(R.drawable.ic_launcher);
AlertDialog dialog = d.create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
d.show();
And then I have in manifest:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
What am I missing??
The function flow before this alert is following:
- Broadcast receiver listens for incoming sms messages.
- Once received, it passes the message to a function in MainActivity using "RunOnUIThread".
- The message is parsed and the alert dialog is shown. Now why the TYPE_SYSTEM_ALERT is not working?? I can see from logcat that the message is parsed ok but still alert dialog is not showing up as system alert. Anyone?