List of usage examples for android.app NotificationManager cancel
public void cancel(int id)
From source file:com.stanleyidesis.quotograph.api.controller.LWQNotificationControllerImpl.java
@Override public void dismissWallpaperGenerationFailureNotification() { NotificationManager notificationManager = (NotificationManager) LWQApplication.get() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIF_ID_GEN_FAILURE); }
From source file:com.stanleyidesis.quotograph.api.controller.LWQNotificationControllerImpl.java
@Override public void dismissSurveyNotification() { NotificationManager notificationManager = (NotificationManager) LWQApplication.get() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIF_ID_SURVEY); }
From source file:com.example.android.alertbuddy.BluetoothLeService.java
/** * This method is not called now, but this can be used * to cancel the notification service.// w w w . j ava2 s . c o m */ private void cancelNotification() { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); mNotificationManager.cancel(NOTIFICATION_ID); }
From source file:net.micode.soundrecorder.RecorderService.java
private void localStopRecording() { if (mRecorder != null) { mNeedUpdateRemainingTime = false; try {// ww w .j a v a2s .c om mRecorder.stop(); } catch (RuntimeException e) { } mRecorder.release(); mRecorder = null; sendStateBroadcast(); showStoppedNotification(); NotificationManager nMgr = (NotificationManager) getApplicationContext() .getSystemService(NOTIFICATION_SERVICE); nMgr.cancel(notifyID); } stopSelf(); }
From source file:yulei.android.client.AndroidMobilePushApp.java
private String getMessage(int numOfMissedMessages) { String message = ""; String linesOfMessageCount = getString(R.string.lines_of_message_count); if (numOfMissedMessages > 0) { String plural = numOfMissedMessages > 1 ? "s" : ""; Log.i("onResume", "missed " + numOfMissedMessages + " message" + plural); tView.append("You missed " + numOfMissedMessages + " message" + plural + ". Your most recent was:\n"); for (int i = 0; i < savedValues.getInt(linesOfMessageCount, 0); i++) { String line = "***" + savedValues.getString("MessageLine" + i, "") + "&&&&"; message += (line + "\n"); }//w ww. j ava 2 s . co m NotificationManager mNotification = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotification.cancel(R.string.notification_number); SharedPreferences.Editor editor = savedValues.edit(); editor.putInt(this.numOfMissedMessages, 0); editor.putInt(linesOfMessageCount, 0); editor.commit(); } else { Log.i("onResume", "no missed messages"); Intent intent = getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { String realData = extras.getString("default"); // message += "___" +realData +"___"; if (realData != null && realData.length() > 2) { //addMarker(decodeJSONforLat(realData),decodeJSONforLon(realData)); if (realData.length() > 2) { Log.e("here", realData); try { Toast toast = Toast.makeText(getApplicationContext(), decodeJSONforName(realData) + decodeJSONforTime(realData), Toast.LENGTH_SHORT); toast.show(); Log.e("heres", "sssss"); //addMarker(decodeJSONforLat(realData),decodeJSONforLon(realData)); addMarker(decodeJSONforLat(realData), decodeJSONforLon(realData), decodeJSONforName(realData), decodeJSONforSentiment(realData), decodeJSONforScore(realData)); message = "\n" + decodeJSONforName(realData) + "\n" + decodeJSONforContent(realData) + "\n"; addHeatMap(decodeJSONforLat(realData), decodeJSONforLon(realData)); //addMarker((Double)decodeObj.get("latitute"),(Double)decodeObj.get("longitude"),(String)decodeObj.get("time"),(String)decodeObj.get("userName")); } catch (Exception e) { Log.e("exception", "Exception throwed"); } } } } } } message += "\n"; return message; }
From source file:com.google.fpl.gim.examplegame.Mission.java
public void cleanup() { Utils.logDebug(TAG, mOverallFictionalProgress.toString()); // Clean up the current moment. if (mData.getCurrentMoment() != null) { mData.getCurrentMoment().end();//w w w . jav a2 s. co m } NotificationManager notificationManager = (NotificationManager) getService() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(MainService.CHOICE_NOTIFICATION_ID); notificationManager.cancel(MainService.FITNESS_STATS_NOTIFICATION_ID); if (mGoogleApiClientWrapper != null) { mGoogleApiClientWrapper.endFitDataSession(TRACKED_DATA_TYPES, this); mGoogleApiClientWrapper = null; } }
From source file:com.amazon.android.tv.tenfoot.ui.fragments.ContentDetailsFragment.java
private void removeNotification(int notificationId) { Log.v(TAG, "removeNotification:" + notificationId); if (notificationId != NO_NOTIFICATION) { NotificationManager notificationManager = (NotificationManager) getActivity() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(notificationId); }//from w w w .j a va2 s . co m }
From source file:eu.istvank.apps.lenslog.activities.MainActivity.java
@Override protected void onNewIntent(Intent intent) { if (intent.hasExtra(NotifySchedulingService.NOTIFICATION_WORN)) { //TODO: save date in intent so that we can retrieve whether it still applies for the current date DateTime utcDateTime = DateTime.today(TimeZone.getTimeZone("UTC")); long utcDateLong = utcDateTime.getMilliseconds(TimeZone.getTimeZone("UTC")); boolean isWorn = intent.getExtras().getBoolean(NotifySchedulingService.NOTIFICATION_WORN); onUpdateWorn(utcDateLong, isWorn); // cancel notification NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NotifySchedulingService.NOTIFICATION_ID); }//from w w w . j a v a 2 s .c om super.onNewIntent(intent); }
From source file:com.y59song.PrivacyGuard.MyVpnService.java
@Override public void deleteNotification(int id) { NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(id); }
From source file:com.tct.mail.NotificationActionIntentService.java
@Override protected void onHandleIntent(final Intent intent) { final Context context = this; final String action = intent.getAction(); // TS: chao.zhang 2015-09-21 EMAIL FEATURE-585337 ADD_S //NOTE: handle the refresh intent. if (ACTION_REFRESH.equals(action)) { boolean cleanStatus = intent.getBooleanExtra(NotificationUtils.EXTRA_NEED_CLEAN_STATUS, false); long boxId = intent.getLongExtra(NotificationUtils.EXTRA_OUTBOX_ID, -1); //after click the action,cancel the notification. int notificationId = intent.getIntExtra(NotificationUtils.EXTRA_FAIL_NOTIFICATION_ID, 0); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(notificationId); if (boxId == -1) { LogUtils.e(LOG_TAG,//w w w .j a v a 2 s.com "can't find the oubox during handle Intent ACTION_REFRESH in NotificationActionIntentService#onHandleIntent"); return; } Uri refreshUri = intent.getData(); if (cleanStatus && isOutboxNotEmpty(context, boxId)) { // 1.clean failed status cleanFaildMailStatus(context, boxId); // 2.start refresh(sync) the outbox context.getContentResolver().query(refreshUri, null, null, null, null); // 3. show the sending toast // Why add toast to Handler? cause the notificationActionIntentService is // asynchronous,so want show toast, // only must add toast to Main thread. Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), R.string.sending, Toast.LENGTH_SHORT).show(); } }); } return; } // TS: chao.zhang 2015-09-21 EMAIL FEATURE-585337 ADD_E else if (ACTION_CALENDAR_NEVER_ASK_AGAIN.equals(action)) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { mNotificationManager.cancel(NotificationController.EXCHANGE_NEWCALENDAR_NOTIFICATION_ID); } MailPrefs.get(context).setIgnoreExchangeCalendarPermission(true); //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD return; } else if (ACTION_CONTACTS_NEVER_ASK_AGAIN.equals(action)) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { mNotificationManager.cancel(NotificationController.EXCHANGE_NEWCONTACTS_NOTIFICATION_ID); } MailPrefs.get(context).setIgnoreExchangeContactPermission(true); //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD return; } else if (ACTION_STORAGE_NEVER_ASK_AGAIN.equals(action)) { //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD_S NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { mNotificationManager.cancel(NotificationController.EXCHANGE_NEWSTORAGE_NOTIFICATION_ID); } MailPrefs.get(context).setIgnoreExchangeStoragePermission(true); //TS: zheng.zou 2016-1-22 EMAIL BUGFIX-1431088 ADD_E } /* * Grab the alarm from the intent. Since the remote AlarmManagerService fills in the Intent * to add some extra data, it must unparcel the NotificationAction object. It throws a * ClassNotFoundException when unparcelling. * To avoid this, do the marshalling ourselves. */ final NotificationAction notificationAction; final byte[] data = intent.getByteArrayExtra(EXTRA_NOTIFICATION_ACTION); if (data != null) { final Parcel in = Parcel.obtain(); in.unmarshall(data, 0, data.length); in.setDataPosition(0); notificationAction = NotificationAction.CREATOR.createFromParcel(in, NotificationAction.class.getClassLoader()); } else { LogUtils.wtf(LOG_TAG, "data was null trying to unparcel the NotificationAction"); return; } final Message message = notificationAction.getMessage(); final ContentResolver contentResolver = getContentResolver(); LogUtils.i(LOG_TAG, "Handling %s", action); logNotificationAction(action, notificationAction); if (notificationAction.getSource() == NotificationAction.SOURCE_REMOTE) { // Skip undo if the action is bridged from remote node. This should be similar to the // logic after the Undo notification expires in a regular flow. LogUtils.d(LOG_TAG, "Canceling %s", notificationAction.getNotificationId()); NotificationManagerCompat.from(context).cancel(notificationAction.getNotificationId()); NotificationActionUtils.processDestructiveAction(this, notificationAction); NotificationActionUtils.resendNotifications(context, notificationAction.getAccount(), notificationAction.getFolder()); return; } if (ACTION_UNDO.equals(action)) { NotificationActionUtils.cancelUndoTimeout(context, notificationAction); NotificationActionUtils.cancelUndoNotification(context, notificationAction); } else if (ACTION_ARCHIVE_REMOVE_LABEL.equals(action) || ACTION_DELETE.equals(action)) { // All we need to do is switch to an Undo notification NotificationActionUtils.createUndoNotification(context, notificationAction); NotificationActionUtils.registerUndoTimeout(context, notificationAction); } else { if (ACTION_UNDO_TIMEOUT.equals(action) || ACTION_DESTRUCT.equals(action)) { // Process the action NotificationActionUtils.cancelUndoTimeout(this, notificationAction); NotificationActionUtils.processUndoNotification(this, notificationAction); } else if (ACTION_MARK_READ.equals(action)) { final Uri uri = message.uri; final ContentValues values = new ContentValues(1); values.put(UIProvider.MessageColumns.READ, 1); contentResolver.update(uri, values, null, null); } NotificationActionUtils.resendNotifications(context, notificationAction.getAccount(), notificationAction.getFolder()); } }