How do I get an Android message notification dialog on top of other activities?
I am searching for a solution to this problem and still not yet got the solution. Right now, I am developing a social networking app in which I need to show a notification message dialog whenever the user gets some message from another and to achieve that I have used the broadcast receiver and it is working fine.
The problem is how to show the notification dialog on top of another application.
Yes, it is possible. The Main.xml layout has one edit text and button. The Messagebox layout has one button. Here you can change message layout to whatever you want.
File MyScheduledReceiver.java:
Main Activity:
MessageBox:
And add these two lines in the Android manifest XML file:
Filestyle.xml:
As others have said in their responses, launching an Activity from the background in order to get the user's attention is discouraged. However, some situations call for this; examples in Android itself include clock alarms, incoming calls, and low battery alerts.
In Gingerbread the fullScreenIntent field was added to Notification objects; this is a standard and convenient way to post a Notification that also launches an Activity to really get the user's attention. As of Gingerbread, the platform components I listed above (alarms, etc.) all use this technique to show their alerts. This is the recommended way to do what you're asking.
As stated in the documentation on Status bar notifications:
Therefore, I strongly advice you against doing that, but you should use a status bar notification instead.