List of usage examples for android.app NotificationManager cancel
public void cancel(String tag, int id)
From source file:com.metinkale.prayerapp.vakit.WidgetService.java
public static void updateOngoing() { extractColors();// w w w . jav a 2 s .c o m NotificationManager nm = (NotificationManager) App.getContext() .getSystemService(Context.NOTIFICATION_SERVICE); for (int i = mOngoing.size() - 1; i >= 0; i--) { long id = mOngoing.get(i); Times t = Times.getTimes(id); if ((t == null) || !t.isOngoingNotificationActive()) { nm.cancel(id + "", NotIds.ONGOING); mOngoing.remove(i); } } List<Long> ids = Times.getIds(); for (long id : ids) { Times t = Times.getTimes(id); if ((t != null) && t.isOngoingNotificationActive() && !mOngoing.contains(id)) { mOngoing.add(id); } } LocalDate cal = LocalDate.now(); String[] left_part = App.getContext().getResources().getStringArray(R.array.lefttext_part); for (long id : mOngoing) { Times t = Times.getTimes(id); String[] dt = { t.getTime(cal, 0), t.getTime(cal, 1), t.getTime(cal, 2), t.getTime(cal, 3), t.getTime(cal, 4), t.getTime(cal, 5) }; boolean icon = Prefs.showOngoingIcon(); boolean number = Prefs.showOngoingNumber(); Crashlytics.setBool("showIcon", icon); Crashlytics.setBool("showNumber", number); Notification noti; if (Prefs.getAlternativeOngoing()) { RemoteViews views = new RemoteViews(App.getContext().getPackageName(), R.layout.notification_layout); int[] timeIds = { R.id.time0, R.id.time1, R.id.time2, R.id.time3, R.id.time4, R.id.time5 }; int[] vakitIds = { R.id.imsak, R.id.gunes, R.id.ogle, R.id.ikindi, R.id.aksam, R.id.yatsi }; int next = t.getNext(); if (Prefs.getVakitIndicator().equals("next")) next++; for (int i = 0; i < dt.length; i++) { if ((next - 1) == i) { views.setTextViewText(timeIds[i], Html.fromHtml("<strong><em>" + Utils.fixTime(dt[i]) + "</em></strong>")); } else { views.setTextViewText(timeIds[i], Utils.fixTime(dt[i])); } } for (int i = 0; i < dt.length; i++) { if ((next - 1) == i) { views.setTextViewText(vakitIds[i], Html.fromHtml("<strong><em>" + Vakit.getByIndex(i).getString() + "</em></strong>")); } else { views.setTextViewText(vakitIds[i], Vakit.getByIndex(i).getString()); } } views.setTextViewText(R.id.time, t.getLeft(t.getNext(), false)); views.setTextViewText(R.id.city, t.getName()); views.setTextColor(R.id.imsak, COLOR_1ST); views.setTextColor(R.id.gunes, COLOR_1ST); views.setTextColor(R.id.ogle, COLOR_1ST); views.setTextColor(R.id.ikindi, COLOR_1ST); views.setTextColor(R.id.aksam, COLOR_1ST); views.setTextColor(R.id.yatsi, COLOR_1ST); views.setTextColor(R.id.time0, COLOR_1ST); views.setTextColor(R.id.time1, COLOR_1ST); views.setTextColor(R.id.time2, COLOR_1ST); views.setTextColor(R.id.time3, COLOR_1ST); views.setTextColor(R.id.time4, COLOR_1ST); views.setTextColor(R.id.time5, COLOR_1ST); views.setTextColor(R.id.time, COLOR_1ST); views.setTextColor(R.id.city, COLOR_1ST); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { long left = t.getLeftMinutes(t.getNext()); noti = new Notification.Builder(App.getContext()).setContent(views) .setContentIntent(Main.getPendingIntent(t)) .setSmallIcon(icon ? (number ? Icon.createWithBitmap(getIconFromMinutes(left)) : Icon.createWithResource(App.getContext(), R.drawable.ic_abicon)) : Icon.createWithResource(App.getContext(), R.drawable.ic_placeholder)) .setOngoing(true).build(); } else { noti = new NotificationCompat.Builder(App.getContext()).setContent(views) .setContentIntent(Main.getPendingIntent(t)) .setSmallIcon(icon ? R.drawable.ic_abicon : R.drawable.ic_placeholder).setOngoing(true) .build(); } } else { int n = t.getNext(); String sum = App.getContext().getString(R.string.leftText, Vakit.getByIndex(n - 1).getString(), left_part[n], t.getLeft().substring(0, 5)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { long left = t.getLeftMinutes(t.getNext()); noti = new Notification.InboxStyle( new Notification.Builder(App.getContext()) .setContentTitle(t.getName() + " (" + t.getSource() + ")").setContentText("") .setLargeIcon(mAbIcon) .setSmallIcon(icon ? (number ? Icon.createWithBitmap(getIconFromMinutes(left)) : Icon.createWithResource(App.getContext(), R.drawable.ic_abicon)) : Icon.createWithResource(App.getContext(), R.drawable.ic_placeholder)) .setContentInfo(sum).setContentIntent(Main.getPendingIntent(t)) .setOngoing(true)) .addLine(Vakit.getByIndex(0).getString() + ": " + Utils.fixTime(dt[0])) .addLine(Vakit.GUNES.getString() + ": " + Utils.fixTime(dt[1])) .addLine(Vakit.OGLE.getString() + ": " + Utils.fixTime(dt[2])) .addLine(Vakit.IKINDI.getString() + ": " + Utils.fixTime(dt[3])) .addLine(Vakit.AKSAM.getString() + ": " + Utils.fixTime(dt[4])) .addLine(Vakit.YATSI.getString() + ": " + Utils.fixTime(dt[5])) .setSummaryText("").build(); } else { noti = new NotificationCompat.InboxStyle(new NotificationCompat.Builder(App.getContext()) .setContentTitle(t.getName() + " (" + t.getSource() + ")").setContentText("") .setLargeIcon(mAbIcon) .setSmallIcon(icon ? R.drawable.ic_abicon : R.drawable.ic_placeholder) .setContentInfo(sum).setContentIntent(Main.getPendingIntent(t)).setOngoing(true)) .addLine(Vakit.getByIndex(0).getString() + ": " + Utils.fixTime(dt[0])) .addLine(Vakit.GUNES.getString() + ": " + Utils.fixTime(dt[1])) .addLine(Vakit.OGLE.getString() + ": " + Utils.fixTime(dt[2])) .addLine(Vakit.IKINDI.getString() + ": " + Utils.fixTime(dt[3])) .addLine(Vakit.AKSAM.getString() + ": " + Utils.fixTime(dt[4])) .addLine(Vakit.YATSI.getString() + ": " + Utils.fixTime(dt[5])) .setSummaryText("").build(); } } if (Build.VERSION.SDK_INT >= 16) { noti.priority = Notification.PRIORITY_LOW; } noti.when = icon ? System.currentTimeMillis() : 0; try { nm.notify(id + "", NotIds.ONGOING, noti); } catch (Exception e) { Crashlytics.logException(e); } } }
From source file:de.ub0r.android.websms.WebSMSReceiver.java
/** * Cleans up after a message sending has been completed (successfully or not). * * @param context context//from w w w.j a va 2 s. c om * @param command {@link ConnectorCommand} */ private static void messageCompleted(final Context context, final ConnectorCommand command) { long msgId = command.getMsgId(); // clear notification NotificationManager mNotificationMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationMgr.cancel(NOTIFICATION_RESENDING_TAG, (int) msgId); mNotificationMgr.cancel(NOTIFICATION_CANCELLING_RESEND_TAG, (int) msgId); // clear flags resendCancelledMsgIds.remove(msgId); }
From source file:de.ub0r.android.websms.WebSMSReceiver.java
/** * Displays notification about cancelling a resend. * * @param context context//from w w w .j ava2 s. c om * @param command {@link ConnectorCommand} */ private static void displayCancellingResendNotification(final Context context, final ConnectorCommand command) { long msgId = command.getMsgId(); // on click, do nothing PendingIntent pIntent = PendingIntent.getActivity(context, (int) msgId, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder b = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.stat_notify_resending) .setContentTitle(context.getString(R.string.cancelling_resend)) .setContentText(getResendSummary(context, command)) .setTicker(context.getString(R.string.cancelling_resend)).setWhen(System.currentTimeMillis()) .setOngoing(true).setContentIntent(pIntent); NotificationManager mNotificationMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationMgr.cancel(NOTIFICATION_RESENDING_TAG, (int) msgId); mNotificationMgr.notify(NOTIFICATION_CANCELLING_RESEND_TAG, (int) msgId, b.build()); }
From source file:com.socialdisasters.other.service.ChatService.java
public static void cancelNotification(Context context, Long buddyId) { if (buddyId == null) return;/*from w w w . ja va2 s. c o m*/ NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(buddyId.toString(), ChatService.MESSAGE_NOTIFICATION); }
From source file:com.prey.activities.DeviceReadyActivity.java
@Override protected void onResume() { super.onResume(); NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nManager.cancel(PreyConfig.TAG, PreyConfig.NOTIFY_ANDROID_6); }
From source file:com.autburst.picture.FinishedUploadActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.finished);/*from ww w.j a v a 2s . com*/ albumName = getIntent().getStringExtra(UploadService.ALBUM_NAME); setButtons(); //Toast.makeText(this, "FinishedUploadActivity called for " + albumName, Toast.LENGTH_LONG); Log.d(TAG, "FinishedUploadActivity called for " + albumName); NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mgr.cancel(albumName, Uploader.NOTE_ID); }
From source file:net.forkk.autocron.data.rule.TestRule.java
/** * Called when the automation service is destroyed. This should perform all necessary cleanup. *///from w ww.java2s . c o m @Override public void onDestroy() { final AutomationService service = getService(); NotificationManager notificationManager = (NotificationManager) service .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_TAG, getId()); service.unregisterIntentListener(mIntentListenerId); }
From source file:net.forkk.autocron.data.action.OngoingNotificationAction.java
/** * Called when the automation service is destroyed. This should perform all necessary cleanup. *//*from w w w . j a v a 2s . c o m*/ @Override protected void onDestroy() { final AutomationService service = getService(); NotificationManager notificationManager = (NotificationManager) service .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_TAG, getId()); }
From source file:net.forkk.autocron.data.action.OngoingNotificationAction.java
/** * Called when the action's automation deactivates. *///from www . jav a 2s.co m @Override public void onDeactivate() { final AutomationService service = getService(); NotificationManager notificationManager = (NotificationManager) service .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_TAG, getId()); }
From source file:org.deviceconnect.android.deviceplugin.host.recorder.AbstractPreviewServerProvider.java
/** * Notification?./*from ww w .ja v a 2 s .c o m*/ */ public void hideNotification() { NotificationManager manager = (NotificationManager) mContext.getSystemService(Service.NOTIFICATION_SERVICE); manager.cancel(getId(), getNotificationId()); }