问题
I upgraded my Nexus One a few days ago with 2.2 (Froyo). This morning when I went to use it I saw a Dialog sitting atop the home/launcher screen notifying me that an update was available and that I could choose to upgrade now or later.
My question is, what API mechanisms is this using to show a Dialog (perhaps an AlertDialog) atop the home screen? Having written an Android app, it was my understanding that Dialogs could only be shown atop an Activity, and that a Service cannot show a Dialog (only a Toast).
Is Google perhaps skinning an Activity to look like a Dialog? Is there a new API method available for showing a Dialog without needing an Activity?
回答1:
You can theme an activity like the dialog, its been there for a while (i think 1.6, maybe even 1.5)
<activity android:name=".MyActivity" android:theme="@android:style/Theme.Dialog" />
That would produce what I believe you are seeing.
来源:https://stackoverflow.com/questions/3167843/how-does-froyo-display-a-dialog-atop-the-home-screen