Reputation: 1
My application needs to provide an alert to the user no matter where the user is at the time. Also, the user needs to be able to click on the alert to return him to my application which will perform a function.
I can not use Toast, because you can not click a Toast to my knowledge. I am trying to launch a PopupWindow instead with a custom view. However, when I try to show the PopupWindow I get the following error:
02-21 01:07:41.481: E/AndroidRuntime(1707): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
The PopupWindow is prepared from within the onStart method of the Service but an AsyncTask running in the background updates the view and tries to launch the PopupWindow. Is it possible to launch the PopupWindow from the AsyncTask? IF so, how?
The following permission has already been added to my manifest.
uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"
Upvotes: 0
Views: 1078
Reputation: 6433
You might want to use a NotificationManager instead to throw notifications and when the user clicks on the notification, it launches an intent to run your Application.
http://developer.android.com/reference/android/app/NotificationManager.html
http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Upvotes: 1