I'm building an android application with BroadcastReceiver
and I want to show a dialog when onReceive
starts.
I want to show the dialog on the phone (show the user a dialog no matter where he is, like the whatsapp dialog when you get a message).
How I can do that?
Thanks!
If you want to show a dialog from inside your onReceive
of the BroadcastReceiver, inside your broadcast receiver you may start a transparent activity with an alert dialog and NEVER called setContentView()
. The activity will have an transparent view and only the alert dialog will show.
Source: show an alert dialog in broadcast receiver after a system reboot
There are many similar posts which talk about this topic. See below questions for code samples and other reviews on the same:
Hope this will help.
来源:https://stackoverflow.com/questions/17906037/broadcastreceiver-onreceive-open-dialog