set Big Notification - Android Android OS

Android examples for Android OS:Notification

Description

set Big Notification

Demo Code


//package com.java2s;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.support.v4.app.NotificationCompat;

public class Main {

    public static void setBigNotification(Context context, String title,
            String content, String[] lines, String ticker, int num,
            int sIcon, Bitmap bIcon, Class<?> cls) {
        NotificationManager manager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                context);/*from   w ww.j  a va 2  s . c  o m*/
        mBuilder.setNumber(num);
        mBuilder.setSmallIcon(sIcon);
        mBuilder.setLargeIcon(bIcon);
        // 
        mBuilder.setTicker(ticker);
        // ?
        mBuilder.setAutoCancel(true);

        /**
         * NotificationCompat.BigPictureStyle, ?256dp?
         * NotificationCompat.BigTextStyle
         * NotificationCompat.InboxStyle
         * 
         * ?BigPictureStyle BigTextStyle?
         * InboxStyle?
         */
        NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();

        for (String line : lines) {
            style.addLine(line);
        }
        style.setBigContentTitle(title);
        style.setSummaryText(content);
        mBuilder.setStyle(style);

        Intent intent = new Intent(context, cls);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
                intent, PendingIntent.FLAG_UPDATE_CURRENT);

        mBuilder.setContentIntent(pendingIntent);
        manager.notify(0, mBuilder.build());
    }
}

Related Tutorials