Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.app.Notification;
import android.app.NotificationManager;

import android.content.Context;

import android.graphics.Bitmap;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;

import android.support.v4.app.NotificationCompat;

public class Main {
    public static final int NOTIFICATION_ID = 20111;

    public static void notifyWithImage(@NonNull Context context, @NonNull String title, @NonNull String msg,
            @DrawableRes int iconId, @NonNull Bitmap bitmap) {
        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new NotificationCompat.Builder(context).setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL).setContentTitle(title).setContentText(msg)
                .setSmallIcon(iconId).setStyle(new NotificationCompat.BigPictureStyle().setBigContentTitle(title)
                        .setSummaryText(msg).bigPicture(bitmap))
                .build();
        notificationManager.notify(NOTIFICATION_ID, notification);
    }
}