List of usage examples for android.content Context NOTIFICATION_SERVICE
String NOTIFICATION_SERVICE
To view the source code for android.content Context NOTIFICATION_SERVICE.
Click Source Link
From source file:Main.java
private static NotificationManager getNotificationManager(Context context) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); return notificationManager; }
From source file:Main.java
/** * Get the notification manager service. * //from ww w . j av a2s . c o m * @param context * @return {@link NotificationManager} */ public static NotificationManager getManager(final ContextWrapper context) { return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); }
From source file:Main.java
public static void cancelNotification(@NonNull Context context, int id) { int finalId = id == 0 ? NOTIFICATION_ID : id; NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(finalId); }
From source file:Main.java
public static void dismissNotification(final Context context, int notificationId) { Log.d(TAG, "dismissNotification notificationID=" + notificationId); NotificationManager notifManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notifManager.cancel(notificationId); }
From source file:Main.java
public static void logout(Context context) { SharedPreferences preferences = context.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.clear();/*from www . ja v a 2 s.c o m*/ editor.commit(); NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); manager.cancelAll(); }
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);/* ww w. ja va2 s. c om*/ mNotificationManager.notify(notifyId, mBuilder.build()); notifyId++; }
From source file:Main.java
public static void notifyBig(@NonNull Context context, @NonNull String title, @NonNull String msg, @DrawableRes int iconId) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new NotificationCompat.Builder(context).setAutoCancel(true) .setContentTitle(title).setDefaults(Notification.DEFAULT_ALL).setContentText(msg) .setSmallIcon(iconId).setStyle(new NotificationCompat.BigTextStyle().setBigContentTitle(title) .setSummaryText(msg).bigText(msg)) .build();/*from w w w.j av a 2s . c o m*/ notificationManager.notify(NOTIFICATION_ID, notification); }
From source file:Main.java
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();/* w ww .j av a 2s . co m*/ notificationManager.notify(NOTIFICATION_ID, notification); }
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 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(//from www . ja v a 2s.c om 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); }