I'm creating a notification which fires an Intent. Here a really shortened excerpt of my code...
Notification notification = new Notification(R.drawable.icon, "notification", System.currentTimeMillis());
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(BackgroundService.this, ConnectionHandler.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.addFlags(Intent.FLAG_FROM_BACKGROUND);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, getString(R.string.notification_title), getString(R.string.notification_body), pendingIntent);
notification.flags |= notification.FLAG_AUTO_CANCEL;
nm.notify(1, notification);
In my intent (ConnectionHandler.class
), I'd like to show an AlertDialog, which works. But I'd like the AlertDialog to show up without opening a new UI-Window. The best for me was if the AlertDialog simply appears without anything else when tapping the notification-entry.
Any idea is appreciated.
Regards, Tobi
From the Dev Guide:
Showing a Dialog
A dialog is always created and displayed as a part of an Activity.
The easy alternative is to create a very basic Activity
, with nothing showing up except the dialog, and calling finish()
as soon as the dialog is dismissed.
Create transparent Activity like below:
How do I create a transparent Activity on Android?
and combine it with dialog theme.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With