如何提示用户一个警告对话框而不是在我的应用程序forground?我的、是在、而不、对话框

2023-09-04 03:39:41 作者:失控Insane

我想向用户显示一个警告对话框中的消息,他可以选择是/否 但我想这样做,即使是自然而然的,主要在我的应用程序不forground,

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)..

该怎么做? 我成功做到警报..但它想出了只是当我的应用程序forground:/ 使用本指南: http://www.androidhive.info/ 2011/09 /如何对出现警报,对话功能于安卓/

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/

请帮我, 感谢的。

推荐答案

您不能,AFAIK,一个对话框需要一个活动。你有可能会满足您的需求的一个选择是创建一个活动对话主题并称之为在接收。所有你需要做的,使它看起来像一个 AlertDialog 是添加

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"

<活性GT; 清单标记。

的BroadcastReceiver