show Notification Big Text Style - Android Android OS

Android examples for Android OS:Notification Show

Description

show Notification Big Text 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 showNotificationBigTextStyle(Context context,
            String text) {// w w  w . ja v a  2 s  . c o  m
        showNotificationWithStyle(
                context,
                getNewID(),
                new NotificationCompat.BigTextStyle()
                        .setSummaryText(
                                context.getString(R.string.summary_text))
                        .setBigContentTitle("Big Text Style").bigText(text));
    }
    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