Android的 - 如何显示在本机屏幕的对话? [英] Android - How to display a dialog over a native screen?

查看:125
本文介绍了Android的 - 如何显示在本机屏幕的对话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人能知道如何弹出一个对话框,屏幕向上超过原生的Andr​​oid屏幕?

I was wondering if anyone can tell if how to pop a dialog screen up over a native Android screen?

我现在有一个陷阱拨出电话并停止它的应用程序,那么我想弹出一个对话框,将接替拨号屏幕,并有尝试调用已被封锁,并允许他们有一定的提醒用户从对话框中新的选项。

I currently have an application that traps an outgoing call and stops it, I then want to pop up a dialog that would take over from the dialler screen and alert the user that there attempt to call has been blocked and allow them have some new options from the dialog.

我知道有些人会说,我应该使用的通知,而不是,但我知道这一点,它不是,它应该工作,我需要能够弹出时调用被困对话的方式。

I know that some people will say that I should use notifications instead but I'm aware of that and its not the way that it should work, I need to be able to pop up a dialog when the call gets trapped.

这是我的对话框code到目前为止

This is my dialog code so far

  AlertDialog LDialog = new AlertDialog.Builder(context)
     .setTitle("Call Blocked")
     .setMessage("Call Blocked, reroute call?")
     .setPositiveButton("ok", null).create();
      LDialog.show();

我presume我必须以某种方式获取上下文是拨号器屏幕?

I presume I have to somehow get the context to be that of the dialler screen?

任何人都可以提供任何帮助和援助或教程的链接?

Can anyone offer any help and assistance or links to tutorials?

在此先感谢

推荐答案

。 您可以在清单文件中声明的主题:

For my application I used an activity with the Dialog theme. You can declare the theme in the manifest file :

<activity android:name="PopupActivity"
  android:launchMode="singleInstance" android:excludeFromRecents="true"
  android:taskAffinity="" android:theme="@android:style/Theme.Dialog" />

  • 使用 launcheMode =singleInstance taskAffinity =如果您的弹出是从主应用程序分开。否则,用户可以单击后退按钮,返回到应用程序的previous活动。
  • excludeFromRecents =真正的来避免你的弹出窗口出现在最近的任务(长preSS家)
  • 主题=@安卓风格/ Theme.Dialog设置对话框主题
    • use launcheMode="singleInstance" and taskAffinity="" if your popup is detached from your main application. Otherwise user may click the back button and return to the previous activity of your application.
    • excludeFromRecents="true" to avoid your popup to appear in recent tasks (long press home)
    • theme="@android:style/Theme.Dialog" to set the Dialog theme.
    • 这篇关于Android的 - 如何显示在本机屏幕的对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆