AlertDialog in BroadcastReceiver

I am trying to create an application that can use android as a fax machine, IE Send the image as a fax or receive a fax and save it as a photo. So far, I'm starting from scratch and making sure that I can intercept the call at the discretion of users. I have a receiver registered in the manifest of my program with the Phone_State filter, which notes when the state has changed (incoming IE call).

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

Full error message below

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)

From what I saw in the AlertDialog code, it conveys the context as well as the Window and WindowManager, and I think this is a failure, is there a better way or something else that I should use that could challenge the screen?

+3
source share
1 answer

-, Android. , .

, BroadcastReceiver Activity, . startActivity(), Activity (, , ), , .

+3

All Articles