show Notification Inbox Style - Android Android OS

Android examples for Android OS:Notification Show

Description

show Notification Inbox Style

Demo Code

// Use of this source code is governed by the MIT license that can be found
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.app.NotificationCompat.WearableExtender;
import android.support.v4.app.RemoteInput;

public class Main{
    private static int NOTIFICATION_ID = 0;
    public static void showNotificationInboxStyle(Context context) {
        showNotificationWithStyle(/*from ww w.j  av a2  s .c o  m*/
                context,
                getNewID(),
                new NotificationCompat.InboxStyle()
                        .setSummaryText(
                                context.getString(R.string.summary_text))
                        .setBigContentTitle("Inbox Style")
                        .addLine("Line 1").addLine("Line 2"));
    }
    private static void showNotificationWithStyle(Context context, int id,
            NotificationCompat.Style style) {
        NotificationManagerCompat.from(context).notify(
                id,
                new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setStyle(style).build());
    }
    private static synchronized int getNewID() {
        return NOTIFICATION_ID++;
    }
}

Related Tutorials