Reputation: 53
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:
Upvotes: 3
Views: 4888
Reputation: 3971
The required permission is only for system apps:
<permission android:name="android.permission.SYSTEM_ALERT_WINDOW"
android:protectionLevel=
"signature|preinstalled|appop|pre23|development"/>
Upvotes: 0