問題描述
我有一個響應警報的應用程序 - 在進入下一個屏幕之前,我確實需要顯示帶有密碼輸入的警報;問題是我似乎無法顯示來自廣播接收器的對話框 - 那么如何在收到警報時顯示對話框密碼輸入?
I've got an app that responds to an Alert - and I really need to show an alert with a password entry before going on to the next screen; the trouble is I don't seem to be able to show a dialog from a broadcast receiver -- so how can I show a dialog password entry upon receiving an alert?
推薦答案
創建一個activity,使用Theme.Dialog
,調用startActivity()
打開它.雖然您不能使用真正的"Dialog
,但您可以創建一個看起來像 Dialog
的 UI.
Create an activity, using Theme.Dialog
, and call startActivity()
to open it. While you cannot use a "real" Dialog
, you can create a UI that looks like a Dialog
.
請記住,根據廣播彈出活動可能會極大地激怒某些用戶,他們可能不喜歡您的對話出現在他們的游戲或短信對話或其他任何事情的中間.您可能希望考慮實際提出一個 Notification
,然后在他們打開該 Notification
時顯示對話框.
Bear in mind that popping up an activity based on a broadcast may greatly irritate some users, who might not appreciate your dialog appearing in the middle of their game or text message conversation or whatever. You may wish to consider actually raising a Notification
, then displaying the dialog when they open up that Notification
.
這篇關于Android廣播接收器顯示一個對話框?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!