Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.NotificationManager;
import android.content.Context;

import android.support.v4.app.NotificationCompat;
import java.util.ArrayList;

public class Main {
    private static int notifyId = 0;

    public static void sendExtendedNotification(Context context, String smTitle, String smMsg,
            ArrayList<String> lgMsg) {

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(android.R.drawable.alert_light_frame).setContentTitle(smTitle).setContentText(smMsg);

        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

        // Sets a title for the Inbox in expanded layout
        inboxStyle.setBigContentTitle(smTitle);

        // Moves events into the expanded layout
        for (int i = 0; i < lgMsg.size(); i++) {
            inboxStyle.addLine(lgMsg.get(i));
        }

        // Moves the expanded layout object into the notification object.
        mBuilder.setStyle(inboxStyle);

        NotificationManager mNotificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);

        //Update the ID entered if it exists, create a new one if it doesn't
        mNotificationManager.notify(notifyId, mBuilder.build());

        notifyId++;
    }
}