我想知道是否有人能告诉我如何在原生Android屏幕上弹出对话框屏幕?
我目前有一个应用程序,捕获并停止呼出,然后我想弹出一个对话框,它将接管拨号器屏幕,并警告用户,那里的尝试呼叫已被阻止,并允许他们从对话框中有一些新的选项。
我知道有些人会说我应该使用通知,但我知道这不是它应该工作的方式,当呼叫陷入陷阱时,我需要能够弹出一个对话框。
到目前为止,这是我的对话框代码
AlertDialog LDialog = new AlertDialog.Builder(context)
.setTitle("Call Blocked")
.setMessage("Call Blocked, reroute call?")
.setPositiveButton("ok", null).create();
LDialog.show();
我想我必须以某种方式获得背景是拨号器的屏幕?
有人可以提供任何帮助和帮助或教程的链接吗?
提前感谢
发布于 2010-01-27 21:52:51
对于我的应用程序,我使用了一个以Dialog
为主题的活动。您可以在清单文件中声明主题:
<activity android:name="PopupActivity"
android:launchMode="singleInstance" android:excludeFromRecents="true"
android:taskAffinity="" android:theme="@android:style/Theme.Dialog" />
如果弹出窗口与主应用程序分离,则
launcheMode="singleInstance"
和taskAffinity=""
。否则,用户可以单击后退按钮并返回到application.excludeFromRecents="true"
的上一个活动,以避免弹出窗口出现在最近的任务中(长按home)theme="@android:style/Theme.Dialog"
可设置对话主题。发布于 2013-07-20 03:02:43
如何在代码中获得launchMode = singleTask的等价物
我还没有看到如何以编程方式设置这些标志的清晰解释,因此我将在这里包含我的结果。tldr:您必须设置FLAG_ACTIVITY_NEW_TASK和FLAG_ACTIVITY_MULTIPLE_TASK。
如果你直接从你的应用程序启动,你的对话框将出现在你的应用程序的上一个活动的顶部。但如果你使用AlarmManager的PendingIntent广播来启动你的“对话”,你有时间切换到另一个应用,这样你就可以看到你的“对话”会出现在其他应用之上,前提是样式设置得当,以显示它背后的内容。
显然,一个人应该负责什么时候在其他应用程序上显示对话框是合适的。
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// you have to set these flags here where you receive the broadcast
// NOT in the code where you created your pendingIntent
Intent scheduledIntent = new Intent(context, AlertAlarmActivity.class);
scheduledIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
scheduledIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
context.startActivity(scheduledIntent);
https://stackoverflow.com/questions/2147144
复制相似问题