I'm trying to build a service which runs in the background and pops up an alert dialog even when you are not in the application screen currently. I'm using an alarm manager. My problem is that when my alert dialog activity pops up - it shows the application activity as background. In other words, I don't want the alert dialog to change the current background and after the user is clicking "OK" it will be back to the same state, and not to my application. How can I do that ?
Asked
Active
Viewed 3,403 times
1 Answers
3
The easiest way would probably be to let the service pop up a new activity. Either you make the activity itself look like a dialog by adding the proper theme in the AndroidManifest.xml:
<activity android:name=".DialogActivity" android:theme="@android:style/Theme.Dialog">
or you make a completely transparent activity that shows a dialog when it starts.

Albin
- 4,180
- 2
- 27
- 19
-
I think you misunderstood me. I do use the line you have wrote, and my activity alert dialog does shows. But I want the background of that activity will be the current user view. For example, if he's in his mobile home, I want the dialog to pop and after he will click "OK", he will return to his mobile home. – ohadinho Nov 19 '11 at 15:52
-
Ah, sorry! How about adding the FLAG_ACTIVITY_NEW_TASK to the starting Intent? – Albin Nov 19 '11 at 16:00
-
Tried it. Here is my code from the service: `private void showAlertDialog() { Intent dialog = new Intent(getApplicationContext(), AlertDialogActivity.class); dialog.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dialog); }` – ohadinho Nov 19 '11 at 16:05
-
Sorry, that was an obvious one, since you're starting it from a Service. Did you set the launchMode="singleInstance" in the manifest for the DialogActivity? – Albin Nov 19 '11 at 16:28