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;

public class Main {
    private static int notifyId = 0;

    public static void sendBasicNotification(Context context, String title, String message) {
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(android.R.drawable.alert_light_frame).setContentTitle(title).setContentText(message);

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

        mBuilder.setAutoCancel(true);

        mNotificationManager.notify(notifyId, mBuilder.build());
        notifyId++;
    }
}