问题
i want to show the user an alert dialog message, that he can choose yes/no but i want to do that automatical even and mainly when my app is not forground,
like clock alarm, that can jump up to screen in any situation (even if user in call)..
how to do that? i succeed to do alert.. but its came up just when my app is forground :/ using this guide: http://www.androidhive.info/2011/09/how-to-show-alert-dialog-in-android/
please help me, thank's.
回答1:
You can't, AFAIK, a Dialog
needs an Activity
. An option you have that may satisfy your needs is to create an Activity
with a Dialog Theme
and call this in a Receiver
. All you need to do to make it look like an AlertDialog
is to add
android:theme="@android:style/Theme.Dialog"
to the <activity>
tag in the manifest
.
BroadcastReceiver
来源:https://stackoverflow.com/questions/18240413/how-to-prompt-to-user-an-alert-dialog-but-not-when-my-app-is-forground