2

I'm using this code to show a notification to user from code :

 Intent intent = new Intent(this, this.getClass());
    PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.icon)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.icon))
            .setContentTitle("Notification!")
            .setContentText("Hello word")
            .setContentIntent(pi)
            .setDefaults(NotificationCompat.DEFAULT_ALL)
            .setPriority(NotificationCompat.PRIORITY_MAX);

    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(0, mBuilder.build());

This is juste adding the notification in the notification screen (and also the icon of my appliaction in the status bar)

But how can I have a preview of this notification on top of screen ?

John smith
  • 355
  • 4
  • 17
  • This feature is called "Heads-up Notifications". Related question: http://stackoverflow.com/questions/26451893/heads-up-notification-android-lollipop – tmh Dec 05 '16 at 10:52

0 Answers0