List of usage examples for android.app NotificationManager cancelAll
public void cancelAll()
From source file:com.matze5800.paupdater.Functions.java
public static void Clear(Context context) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancelAll(); }
From source file:vrisini.cordova.plugin.schedule.Schedule.java
/** * Cancel all notifications that were created by this plugin. * * Android can only unregister a specific alarm. There is no such thing * as cancelAll. Therefore we rely on the Shared Preferences which holds * all our alarms to loop through these alarms and unregister them one * by one.// www .ja v a 2 s. c o m */ public static void cancelAll() { SharedPreferences settings = getSharedPreferences(); NotificationManager nc = getNotificationManager(); Map<String, ?> alarms = settings.getAll(); Set<String> alarmIds = alarms.keySet(); for (String alarmId : alarmIds) { cancel(alarmId); } nc.cancelAll(); }
From source file:net.ustyugov.jtalk.Notify.java
public static void cancelAll(Context context) { NotificationManager mng = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mng.cancelAll(); }
From source file:org.smssecure.smssecure.notifications.MessageNotifier.java
private static void cancelActiveNotifications(@NonNull Context context) { NotificationManager notifications = ServiceUtil.getNotificationManager(context); notifications.cancel(SUMMARY_NOTIFICATION_ID); if (Build.VERSION.SDK_INT >= 23) { try {/*from ww w .j a v a 2 s .c o m*/ StatusBarNotification[] activeNotifications = notifications.getActiveNotifications(); for (StatusBarNotification activeNotification : activeNotifications) { notifications.cancel(activeNotification.getId()); } } catch (Throwable e) { // XXX Appears to be a ROM bug, see https://github.com/WhisperSystems/Signal-Android/issues/6043 Log.w(TAG, e); notifications.cancelAll(); } } }
From source file:com.prey.beta.services.PreyBetaRunnerService.java
@Override public void onDestroy() { PreyLogger.d("********************"); PreyLogger.d("PreyRunnerService is going to be destroyed"); PreyConfig preyConfig = PreyConfig.getPreyConfig(PreyBetaRunnerService.this); preyConfig.setMissing(false);//w ww . j a v a2s .c o m NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancelAll(); ActionsController.getInstance(PreyBetaRunnerService.this).finishRunningJosb(); running = false; //PreyLogger.d("PreyRunnerService has been destroyed"); }
From source file:be.ppareit.swiftp.gui.FsNotification.java
private void clearNotification(Context context) { Cat.d("Clearing the notifications"); String ns = Context.NOTIFICATION_SERVICE; NotificationManager nm = (NotificationManager) context.getSystemService(ns); nm.cancelAll(); Cat.d("Cleared notification"); }
From source file:org.ametro.util.WebUtil.java
public static void downloadFileAsync(final Context appContext, final File path, final URI uri, final File temp) { final DownloadContext context = new DownloadContext(); context.Path = path;//from w ww . jav a 2 s.c o m context.IsCanceled = false; context.IsUnpackFinished = false; context.IsFailed = false; final NotificationManager notificationManager = (NotificationManager) appContext .getSystemService(Context.NOTIFICATION_SERVICE); final Handler handler = new Handler(); final Runnable updateProgress = new Runnable() { public void run() { if (context.Notification == null) { context.Notification = new Notification(android.R.drawable.stat_sys_download, "Downloading icons", System.currentTimeMillis()); context.Notification.flags = Notification.FLAG_NO_CLEAR; Intent notificationIntent = new Intent(); context.ContentIntent = PendingIntent.getActivity(appContext, 0, notificationIntent, 0); } if (context.IsFailed) { notificationManager.cancelAll(); context.Notification = new Notification(android.R.drawable.stat_sys_warning, "Icons download failed", System.currentTimeMillis()); context.Notification.setLatestEventInfo(appContext, "aMetro", "Icons downloaded failed", context.ContentIntent); notificationManager.notify(2, context.Notification); } else if (context.IsUnpackFinished) { notificationManager.cancelAll(); context.Notification = new Notification(android.R.drawable.stat_sys_download_done, "Icons unpacked", System.currentTimeMillis()); context.Notification.setLatestEventInfo(appContext, "aMetro", "Icons downloaded and unpacked.", context.ContentIntent); notificationManager.notify(3, context.Notification); } else if (context.Position == 0 && context.Total == 0) { context.Notification.setLatestEventInfo(appContext, "aMetro", "Download icons: connecting server", context.ContentIntent); notificationManager.notify(1, context.Notification); } else if (context.Position < context.Total) { context.Notification.setLatestEventInfo(appContext, "aMetro", "Download icons: " + context.Position + "/" + context.Total, context.ContentIntent); notificationManager.notify(1, context.Notification); } else { context.Notification.setLatestEventInfo(appContext, "aMetro", "Icons unpacking", context.ContentIntent); notificationManager.notify(1, context.Notification); } } }; final Thread async = new Thread() { public void run() { WebUtil.downloadFile(context, uri, temp, false, new IDownloadListener() { public void onBegin(Object context, File file) { DownloadContext downloadContext = (DownloadContext) context; downloadContext.Total = 0; downloadContext.Position = 0; handler.removeCallbacks(updateProgress); handler.post(updateProgress); } public boolean onUpdate(Object context, long position, long total) { DownloadContext downloadContext = (DownloadContext) context; downloadContext.Total = total; downloadContext.Position = position; handler.removeCallbacks(updateProgress); handler.post(updateProgress); return !downloadContext.IsCanceled; } public void onDone(Object context, File file) throws Exception { DownloadContext downloadContext = (DownloadContext) context; File path = downloadContext.Path; ZipUtil.unzip(file, path); downloadContext.IsUnpackFinished = true; handler.removeCallbacks(updateProgress); handler.post(updateProgress); } public void onCanceled(Object context, File file) { DownloadContext downloadContext = (DownloadContext) context; downloadContext.IsCanceled = true; handler.removeCallbacks(updateProgress); handler.post(updateProgress); } public void onFailed(Object context, File file, Throwable reason) { DownloadContext downloadContext = (DownloadContext) context; downloadContext.IsFailed = true; handler.removeCallbacks(updateProgress); handler.post(updateProgress); } }); }; }; async.start(); }
From source file:ti.modules.titanium.android.notificationmanager.NotificationManagerModule.java
@Kroll.method public void cancelAll() { NotificationManager manager = getManager(); if (manager != null) { manager.cancelAll(); } }
From source file:com.meiste.tempalarm.gcm.GcmIntentService.java
private void cancelNotification() { final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancelAll(); }
From source file:com.android.talkbacktests.testsession.NotificationTest.java
private void cancelNotifications() { NotificationManager notificationManager = (NotificationManager) getContext() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancelAll(); }