Home » Android » How to create pop-up notifications like the notification used in whatsapp for android?

How to create pop-up notifications like the notification used in whatsapp for android?

Posted by: admin May 14, 2020 Leave a comment


I want to create notification like the pop-up notification used in WhatsApp application for android devices.

How can i do it?
Since i am a new user I cannot upload the screen shot

please refer this link : http://cdn6.staztic.com/cdn/screenshot/appsdroidnotifythemeicecreamsandwich-1-1.jpg

enter image description here

for the screen shot image and help me 🙂

How to&Answers:

They’re called ‘heads-up’ notifications. This page has a nice explanation.

To summarize, set the priority to High (or Max).

Here is an example in my code:

public static void notify(Context context, int id, int titleResId,
                          int textResId, PendingIntent intent) {
    NotificationManager notificationManager =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    String title = context.getString(titleResId);
    String text = context.getString(textResId);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
    notificationManager.notify(id, builder.build());


Declare a PopUpWindow reference and call initiatePopupWindow() method from where you want to open a pop up window:

private PopupWindow pwindo;

private void initiatePopupWindow() {
try {
// We need to get the instance of the LayoutInflater
LayoutInflater inflater = (LayoutInflater) PopUpWinndowDemoActivity.this
View layout = inflater.inflate(R.layout.screen_popup,
(ViewGroup) findViewById(R.id.popup_element));
pwindo = new PopupWindow(layout, 300, 370, true);
pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);

} catch (Exception e) {

Have an screen_popup.xml for the pop up window like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10sp" >

android:text="Hello!" />



You can achieve it using Dialog theme or by making the activity’s window transparent through setting window background to transparent in theme. Just make your UI is in such a way that it looks like a Dialog.

<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation</item>


I don’t know what whatsapp’s pop-up looks like…

You can use a toast or a dialog