I have issue with displaying AlertDialog from Service. I am able to display custom layout window using Toast or using WindowManager(TYPE_SYSTEM_ALERT or TYPE_SYSTEM_OVERLAY). But, I do not want to use custom layout, I prefer to use nice AlertDialog GUI directly.
Scenario:
- Running Service. No active Activity present.
- On some external event, Service sends Notification
- When user press Notification, Service is informed via PendingIntent and AlertDialog should be displayed (created with
AlertDialog.Builder(this)
)
Error:
ERROR/AndroidRuntime(1063): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
Searching for the answer lead me to impression that I am trying something that is currently not possible (Android 2.2). Or maybe it is.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…