How to display a Dialog from a Service?

you can start by learning on how to create an activity that looks like a dialog (no title bar, transparent background, "floating" effect, etc.) and no, you can't just start a dialog without an activty


We can show dialog from service only if it is a system alert dialog. So, set TYPE_SYSTEM_ALERT window layout parameter to Dialog as follows:

dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

But, it needs SYSTEM_ALERT_WINDOW permission. So, don't forget to add this permissin in Manifest file.

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

Edit: Better option to show dialog is to start activity as one of the below ways.

  1. Start Activity with Dialog Theme (android:theme="@android:style/Theme.Dialog") -(or)
  2. Start Translucent Activity and show Dialog in it.

Note: You should add Intent.FLAG_ACTIVITY_NEW_TASK to intent


I highly, highly, HIGHLY recommend that you DON'T do this (it goes against Android design and UI guidelines). Notifications are the preferred way to accomplish what you are doing (which it sounds as if you have already accomplished).

That being said, if you must do it, I would recommend just using a Dialog themed activity. That way you don't have to start up a separate dialog. Please see http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme for how to do this.