show Notification Big Picture Style - Android Android OS

Android examples for Android OS:Notification Show

Description

show Notification Big Picture 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 showNotificationBigPictureStyle(Context context,
            Bitmap bitmap) {//from   ww  w  .j a  va  2 s .co  m
        showNotificationWithStyle(
                context,
                getNewID(),
                new NotificationCompat.BigPictureStyle()
                        .setSummaryText(
                                context.getString(R.string.summary_text))
                        .setBigContentTitle("Big Picture Style")
                        .bigPicture(bitmap));
    }
    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