How to prompt to user an alert dialog but not when

2019-03-05 08:26发布

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条回答
仙女界的扛把子
2楼-- · 2019-03-05 09:25

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

查看更多
登录 后发表回答