Example usage for android.app NotificationManager notify

List of usage examples for android.app NotificationManager notify

Introduction

In this page you can find the example usage for android.app NotificationManager notify.

Prototype

public void notify(int id, Notification notification) 

Source Link

Document

Post a notification to be shown in the status bar.

Usage

From source file:Main.java

private static void notifyUpdate(Context ctx) {
    if (mNotification == null)
        return;/*from w  w w  . j  a v a2 s.c om*/
    NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(1, mNotification);
}

From source file:Main.java

public static void notify(Context context, String msg, String title, Class<?> toClz, int notifyId) {
    PendingIntent pend = PendingIntent.getActivity(context, 0, new Intent(context, toClz), 0);
    Notification.Builder builder = new Notification.Builder(context);
    int icon = context.getApplicationInfo().icon;
    builder.setContentIntent(pend).setSmallIcon(icon).setWhen(System.currentTimeMillis()).setTicker(msg)
            .setContentTitle(title).setContentText(msg).setAutoCancel(true);

    NotificationManager man = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    man.notify(notifyId, builder.getNotification());
}

From source file:Main.java

public static void updateNotification(Context context, int notifiId, Notification notification) {
    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(notifiId, notification);
}

From source file:Main.java

public static void sendNotification(Context context, int id, Notification notification) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(id, notification);
}

From source file:Main.java

public static void notify(Context context, int id, String title, String detail) {
    Notification notification = new NotificationCompat.Builder(context).setContentTitle(title).setTicker(detail)
            .setContentText(detail).setDefaults(Notification.DEFAULT_ALL)
            .setSmallIcon(android.R.drawable.ic_dialog_alert)
            .setLargeIcon(/*ww  w. j a  va 2s  . com*/
                    BitmapFactory.decodeResource(context.getResources(), android.R.drawable.ic_dialog_alert))
            .build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(id, notification);
}

From source file:com.achep.acdisplay.notifications.NotificationHelper.java

public static void sendNotification(@NonNull Context context, final int id, @NonNull Object... objects) {
    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(id, buildNotification(context, id, objects));
}

From source file:Main.java

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);/*from w  w  w .  jav a 2  s. co m*/

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

From source file:bucci.dev.freestyle.NotificationCreator.java

public static void createTimerRunningNotification(Context context, String startPauseButtonState, long timeLeft,
        TimerType timerType, boolean extraButtonVisibleState) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.bft_icon_gray)
            .setContentTitle(context.getString(R.string.notification_timer_running_text)).setAutoCancel(true)
            .setOngoing(true);// www .j ava2  s  .c o m

    Intent resultIntent = new Intent(context, TimerActivity.class);
    resultIntent.putExtra(StartActivity.TIMER_TYPE, timerType);
    resultIntent.putExtra(TimerActivity.START_PAUSE_STATE_PARAM, startPauseButtonState);
    resultIntent.putExtra(TimerActivity.TIME_LEFT_PARAM, timeLeft);
    if (extraButtonVisibleState)
        resultIntent.putExtra(TimerActivity.SHOW_EXTRA_ROUND_BUTTON_PARAM, true);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(TimerActivity.class);
    stackBuilder.addNextIntent(resultIntent);

    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);

    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(NOTIFICATION_TIMER_RUNNING, builder.build());
}

From source file:ca.hoogit.powerhour.Notifications.Foreground.java

public static void update(Context context, GameModel gameModel) {
    Notification notif = build(context, gameModel);

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

    manager.notify(Constants.NOTIFICATION_ID.FOREGROUND_ID, notif);
}

From source file:com.android.antitheft.util.AntiTheftNotifier.java

public static void sendNotification(String message) {
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
            AntiTheftApplication.getInstance()).setSmallIcon(android.R.drawable.arrow_up_float)
                    .setContentTitle("Ariel").setContentText(message).setAutoCancel(true);

    NotificationManager notificationManager = (NotificationManager) AntiTheftApplication.getInstance()
            .getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}