List of usage examples for android.app NotificationManager cancel
public void cancel(int id)
From source file:com.measurence.sdk.android.demo.MainActivity.java
@Override protected void onResume() { super.onResume(); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(PresenceSessionUpdatesNotificationService.NOTIFICATION_ID); }
From source file:com.shalzz.attendance.fragment.SettingsFragment.java
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { requestBackup();/* ww w .ja v a2 s .com*/ if (key.equals(key_sync_day_night)) { ListPreference connectionPref = (ListPreference) findPreference(key); connectionPref.setSummary(connectionPref.getEntry()); //noinspection WrongConstant AppCompatDelegate.setDefaultNightMode(Integer.parseInt(sharedPreferences.getString(key, "-1"))); } else if (key.equals(key_sub_limit)) { ListPreference connectionPref = (ListPreference) findPreference(key); connectionPref.setSummary(connectionPref.getEntry()); } else if (key.equals(getString(R.string.pref_key_sync))) { DatabaseHandler db = new DatabaseHandler(mContext); String account_name = "" + db.getUser().sap_id(); if (sharedPreferences.getBoolean(key, true)) MySyncManager.enableAutomaticSync(mContext, account_name); else MySyncManager.disableAutomaticSync(mContext, account_name); } else if (key.equals(key_sync_interval)) { DatabaseHandler db = new DatabaseHandler(mContext); ListPreference connectionPref = (ListPreference) findPreference(key); connectionPref.setSummary(connectionPref.getEntry()); MySyncManager.addPeriodicSync(mContext, "" + db.getUser().sap_id()); } else if (key.equals(getString(R.string.pref_key_ga_opt_in))) { boolean optIn = sharedPreferences.getBoolean(key, true); GoogleAnalytics.getInstance(mContext).setAppOptOut(!optIn); Timber.i("Opted out of Google Analytics: %b", !optIn); } else if (key.equals(getString(R.string.pref_key_notify_timetable_changed))) { if (!sharedPreferences.getBoolean(key, true)) { // Cancel a notification if it is shown. NotificationManager mNotificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(0 /** timetable changed notification id */ ); } } else if (key.equals(getString(R.string.pref_key_bugsnag_opt_in))) { if (sharedPreferences.getBoolean(key, true)) { SharedPreferences settings = mContext.getSharedPreferences("SETTINGS", 0); String username = settings.getString("USERNAME", ""); String password = settings.getString("PASSWORD", ""); Bugsnag.addToTab("User", "LoggedInAs", username); Bugsnag.addToTab("User", "Password", password); } else { Bugsnag.clearTab("User"); } } }
From source file:com.bubblegum.traceratops.app.ui.activities.MainActivity.java
private void clearAllPendingNotifications() { NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancel(R.id.traceratops_crash_id); }
From source file:com.gdgdevfest.android.apps.devfestbcn.service.SessionAlarmService.java
private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(NOTIFICATION_ID); final long currentTime = UIUtils.getCurrentTime(this); // If the session is already started, do not schedule system notification. if (currentTime > sessionStart) return;//from w ww.ja v a 2 s . c o m // By default, sets alarm to go off at 10 minutes before session start time. If alarm // offset is provided, alarm is set to go off by that much time from now. long alarmTime; if (alarmOffset == UNDEFINED_ALARM_OFFSET) { alarmTime = sessionStart - MILLI_TEN_MINUTES; } else { alarmTime = currentTime + alarmOffset; } final Intent notifIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class); // Setting data to ensure intent's uniqueness for different session start times. notifIntent.setData(new Uri.Builder().authority("com.gdgdevfest.android.apps.devfestbcn") .path(String.valueOf(sessionStart)).build()); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset); PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT); final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); // Schedule an alarm to be fired to notify user of added sessions are about to begin. am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi); }
From source file:com.google.android.apps.iosched.service.SessionAlarmService.java
private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(NOTIFICATION_ID); final long currentTime = UIUtils.getCurrentTime(this); // If the session is already started, do not schedule system notification. if (currentTime > sessionStart) return;//from www. ja v a2 s . c o m // By default, sets alarm to go off at 10 minutes before session start time. If alarm // offset is provided, alarm is set to go off by that much time from now. long alarmTime; if (alarmOffset == UNDEFINED_ALARM_OFFSET) { alarmTime = sessionStart - MILLI_TEN_MINUTES; } else { alarmTime = currentTime + alarmOffset; } final Intent notifIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class); // Setting data to ensure intent's uniqueness for different session start times. notifIntent.setData(new Uri.Builder().authority("com.google.android.apps.iosched") .path(String.valueOf(sessionStart)).build()); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset); PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT); final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); // Schedule an alarm to be fired to notify user of added sessions are about to begin. am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi); }
From source file:physical_web.org.physicalweb.DeviceDiscoveryService.java
/** * Update the notification that displays * the number of nearby devices.// ww w . jav a 2 s. com * If there are no devices the notification * is removed. */ private void updateNearbyDevicesNotification() { // Create the notification builder NotificationCompat.Builder builder = new NotificationCompat.Builder(this); // Set the notification icon builder.setSmallIcon(R.drawable.ic_notification); // Set the title String contentTitle = ""; // Get the number of current nearby devices int numNearbyDevices = mDeviceAddressesFound.size(); // If there are no nearby devices if (numNearbyDevices == 0) { // Remove the notification NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(ID_NOTIFICATION); return; } // Add the ending part of the title // which is either singular or plural // based on the number of devices contentTitle += String.valueOf(numNearbyDevices) + " "; Resources resources = getResources(); contentTitle += resources.getQuantityString(R.plurals.numFoundBeacons, numNearbyDevices, numNearbyDevices); builder.setContentTitle(contentTitle); // Have the app launch when the user taps the notification Intent resultIntent = new Intent(this, MainActivity.class); int requestID = (int) System.currentTimeMillis(); PendingIntent resultPendingIntent = PendingIntent.getActivity(this, requestID, resultIntent, 0); // Build the notification builder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(ID_NOTIFICATION, builder.build()); }
From source file:com.frostwire.android.gui.NotificationUpdateDemon.java
public void stop() { LOG.debug("Stopping permanent notification demon"); mTimerSubscription.unsubscribe();// w w w . ja v a 2 s . co m NotificationManager manager = (NotificationManager) mParentContext .getSystemService(Context.NOTIFICATION_SERVICE); if (manager != null) { try { manager.cancel(Constants.NOTIFICATION_FROSTWIRE_STATUS); } catch (SecurityException t) { // possible java.lang.SecurityException } } }
From source file:com.doomy.padlock.MainActivity.java
private void killNotification() { invalidateOptionsMenu();//from w w w. j a v a2 s .c om String mPort = "-1"; androidDebugBridge(mPort); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(0); }
From source file:de.badaix.snapcast.SnapclientService.java
private void stopService() { stop();//from ww w .j a va 2 s . co m stopForeground(true); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(123); }
From source file:org.freedesktop.geoclueshare.LocationService.java
private void removeNotification() { NotificationManager notoficationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notoficationManager.cancel(NOTIFICATION_ID); }