問(wèn)題描述
是否可以通過(guò)服務(wù)在安卓設(shè)備的主屏幕上顯示彈出對(duì)話框(AlertDialog)?
Is it possible to show pop up dialog (AlertDialog) in home screen on the android device via services?
推薦答案
您可以使用 Theme.Dialog
主題創(chuàng)建一個(gè) Activity
.在您的 AndroidManifest.xml
文件中,將主題添加到活動(dòng)中,如下所示:
You could create an Activity
with the Theme.Dialog
theme. In your AndroidManifest.xml
file add the theme to the activity, like this:
<activity android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog"></activity>
從您的服務(wù)中只需啟動(dòng)這個(gè)Activity
.您必須使用 Intent.FLAG_ACTIVITY_NEW_TASK
標(biāo)志開(kāi)始活動(dòng).請(qǐng)參閱如何從服務(wù)啟動(dòng)活動(dòng)
From your service simply start this Activity
. You will have to start the activity with the Intent.FLAG_ACTIVITY_NEW_TASK
flag. See How to start an Activity from a Service
這篇關(guān)于在 Android 主屏幕中彈出對(duì)話框的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!