AlertDialog中的BroadcastReceiver [英] AlertDialog in BroadcastReceiver

查看:262
本文介绍了AlertDialog中的BroadcastReceiver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个可以使用Android作为传真机的应用程序,IE发送图片作为传真发送或接收传真,并保存为图片。到目前为止,我从地上爬起来开始,并确保我可以截获一个电话用户自行决定。我已经注册了我的程序的清单与Phone_State的过滤器时,状态已改变其标志(IE来电)的接收器。

I'm trying to create an application that can use the android as a fax machine, IE Send a picture as a fax or receive a fax and save as a picture. So far I'm starting from the ground up and making sure I can intercept a call at the users discretion. I have an Receiver registered in the Manifest of my program with a filter of Phone_State which flags when the state has changed(IE incoming call).

所以,在我的BroadcastReceiver我想有一个AlertDialog弹出,提示用户选择接受传真或打电话,但AlertDialog好像扔android.view.WindowManager $ BadTokenException错误时,它有一个来电。我的code是只是简单的一个的onReceive(背景为arg0,意图ARG1)和我通过将arg0到AlertDialog ...

So on my BroadcastReceiver I'm trying to have an AlertDialog popup prompting the user to either accept as fax or call but the AlertDialog seems to throw a android.view.WindowManager$BadTokenException Error when it has an incoming call. My code is just simple an onReceive(context arg0, intent arg1) and I pass the arg0 to the AlertDialog...

完整的错误信息是低于

08-08 00:16:14.315: ERROR/AndroidRuntime(275): java.lang.RuntimeException: Unable to start receiver com.android.fax.IncomingFax: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
08-08 00:16:14.315: ERROR/AndroidRuntime(275):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2550)
08-08 00:16:14.315: ERROR/AndroidRuntime(275):     at android.app.ActivityThread.access$3000(ActivityThread.java:116)
08-08 00:16:14.315: ERROR/AndroidRuntime(275):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1843)

这是我所看到的AlertDialog code,它传递的背景下,以及一个窗口,窗口管理,我相信这是为什么它的崩溃,有没有更好的方法或别的东西,我应该使用可能覆盖呼叫屏幕?

From what I have seen in the AlertDialog code, it passes the context as well as a Window and WindowManager, which I believe is why it's crashing, is there a better way or something else I should be using which might overlay the call screen?

推荐答案

首先,你不能从Android上的通话音频流。由于这种限制,我不知道你将如何接收传真。

First, you can't get to the in-call audio stream from Android. With that limitation, I have no idea how you are going to receive a fax.

对于你的错误,清单注册的BroadcastReceiver 不是一个活动,因此它不能创造的对话框。你可以在原则上,调用 startActivity()来启动一个活动(也许有主题像一个对话框),但我不知道是否会出现在来电屏幕。

With respect to your error, a manifest-registered BroadcastReceiver is not an Activity, and so it cannot create a dialog. You could, in principle, call startActivity() to start up an Activity (perhaps one themed like a dialog), but I do not know whether or not it would appear over the in-call screen.

这篇关于AlertDialog中的BroadcastReceiver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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