An AlertDialog
can be invoked from a service
which is possible (link for the same), but had a doubt here, like invoking an alert dialog from a android service is against Google UI guidelines or not ? If I do so will my developed application fail certification ?

- 732
- 5
- 16

- 15
- 2
-
`An AlertDialog can be invoked from a service` that's wrong, it can't. – Vladyslav Matviienko Apr 26 '18 at 06:30
2 Answers
An AlertDialog can be invoked from a service which is possible
Not really. The blog post that you link two shows two options:
Do not use
AlertDialog
, but instead use a dialog-themed activityUse
SYSTEM_ALERT_WINDOW
, which is a complicated permission and one that users may not grant to you
Of the two, the first is a much better answer.
like invoking an alert dialog from a android service is against Google UI guidelines or not ?
I do not know what you consider "Google UI guidelines" to be. I do not recall Material Design addressing this issue.
However, popping up a UI from the background is very user-hostile. You do not know what the user is doing in the foreground. For example, if the user is trying to use a navigation app, your dialog may cause a car crash.
Please use a notification — perhaps a heads-up notification — rather than displaying a dialog from the background.
If I do so will my developed application fail certification ?
You would have to ask whoever is certifying your app. There is no standard certification process in Android.
For the Play Store, Google has their app developer policies, and you would need to see whether your dialog would violate any of those policies.

- 986,068
- 189
- 2,389
- 2,491
-
https://developer.android.com/guide/practices/ui_guidelines/activity_task_design Check this link it states that Use the notification system — don't use dialog boxes in place of notifications If your background service needs to notify a user, use the standard notification system — don't use a dialog or toast to notify them. – Murtaza Kapadia Apr 26 '18 at 06:37
-
@MurtazaKapadia: First, that document is deprecated. Second, that document specifically tells you what I did (see "Use the notification system — don't use dialog boxes in place of notifications"). – CommonsWare Apr 26 '18 at 06:40
It highly recomended to not do this, check the below post on stackoverflow Link
And if even want to do that
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
TYPE_SYSTEM_ALERT
window layout parameter to Dialog
need additional permission for this
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

- 1,714
- 2
- 20
- 35