List of usage examples for android.app NotificationManager cancel
public void cancel(int id)
From source file:org.mozilla.gecko.GeckoAppShell.java
private static void removeNotification(int notificationID) { mAlertNotifications.remove(notificationID); NotificationManager notificationManager = (NotificationManager) GeckoApp.mAppContext .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(notificationID); }
From source file:com.money.manager.ex.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Core core = new Core(this); String locale = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .getString(PreferencesConstant.PREF_LOCALE, ""); core.changeLocaleApp(locale);/*from w w w. ja va2 s .com*/ // close notification NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(DropboxServiceIntent.NOTIFICATION_DROPBOX_OPEN_FILE); // check intent is valid if (getIntent() != null && getIntent().getData() != null) { String pathFile = getIntent().getData().getEncodedPath(); // decode try { pathFile = URLDecoder.decode(pathFile, "UTF-8"); // decode file path if (BuildConfig.DEBUG) Log.d(LOGCAT, "Path intent file to open:" + pathFile); if (!core.changeDatabase(pathFile)) { Log.w(LOGCAT, "Path intent file to open:" + pathFile + " not correct!!!"); } } catch (Exception e) { Log.e(LOGCAT, e.getMessage()); } } // check authentication if (savedInstanceState != null) { if (savedInstanceState.containsKey(KEY_IS_AUTHENTICATED)) isAuthenticated = savedInstanceState.getBoolean(KEY_IS_AUTHENTICATED); if (savedInstanceState.containsKey(KEY_IN_AUTHENTICATION)) isInAuthentication = savedInstanceState.getBoolean(KEY_IN_AUTHENTICATION); if (savedInstanceState.containsKey(KEY_ORIENTATION)) { if (core.isTablet()) { if (savedInstanceState .getInt(KEY_ORIENTATION) != getResources().getConfiguration().orientation) { for (int i = 0; i < getSupportFragmentManager().getBackStackEntryCount(); ++i) { getSupportFragmentManager().popBackStack(); } } } } } // init application try { core.initDatabase(); } catch (Exception e) { Log.e(LOGCAT, !TextUtils.isEmpty(e.getMessage()) ? e.getMessage() : "Init database failed"); } // load base currency and compose hash currencies CurrencyUtils currencyUtils = new CurrencyUtils(this); if (!currencyUtils.isInit()) currencyUtils.reInit(); // create a connection to dropbox mDropboxHelper = DropboxHelper.getInstance(getApplicationContext()); // check type mode onCreateFragments(savedInstanceState); // show tips dialog showTipsDialog(savedInstanceState); // show change log and path; if (core.isToDisplayChangelog()) core.showChangelog(); MoneyManagerApplication.showDatabasePathWork(this); // notification send broadcast Intent serviceRepeatingTransaction = new Intent(getApplicationContext(), MoneyManagerBootReceiver.class); getApplicationContext().sendBroadcast(serviceRepeatingTransaction); }
From source file:org.telegram.ui.LaunchActivity.java
@Override protected void onResume() { super.onResume(); if (notificationView == null && getLayoutInflater() != null) { notificationView = (NotificationView) getLayoutInflater().inflate(R.layout.notification_layout, null); }/* w ww . j a va2 s. c o m*/ fixLayout(); checkForCrashes(); checkForUpdates(); ApplicationLoader.resetLastPauseTime(); supportInvalidateOptionsMenu(); updateActionBar(); try { NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(1); MessagesController.getInstance().currentPushMessage = null; } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:com.frostwire.android.gui.activities.MainActivity.java
private void onDownloadCompleteNotification(Intent intent) { controller.showTransfers(TransferStatus.COMPLETED); TransferManager.instance().clearDownloadsToReview(); try {//w w w . j av a 2 s . co m NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.cancel(Constants.NOTIFICATION_DOWNLOAD_TRANSFER_FINISHED); } Bundle extras = intent.getExtras(); if (extras != null) { String downloadCompletePath = extras.getString(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH); if (downloadCompletePath != null) { File file = new File(downloadCompletePath); if (file.isFile()) { UIUtils.openFile(this, file.getAbsoluteFile()); } } } } catch (Throwable e) { LOG.warn("Error handling download complete notification", e); } }
From source file:com.android.mms.quickmessage.QuickMessagePopup.java
/** * Clears the status bar notification and, optionally, mark all messages as read * This is used to clean up when we are done with all qm's * * @param markAsRead - should remaining qm's be maked as read? *//*from www . ja v a2 s. c o m*/ private void clearNotification(boolean markAsRead) { // Dismiss the notification that brought us here. NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(MessagingNotification.NOTIFICATION_ID); // Mark all contained conversations as seen if (markAsRead) { markAllMessagesRead(); } // Clear the messages list mMessageList.clear(); mPagerAdapter.notifyDataSetChanged(); if (DEBUG) { Log.d(LOG_TAG, "clearNotification(): Message list cleared. Size = " + mMessageList.size()); } }
From source file:com.flipzu.flipzu.Recorder.java
private void clearNotifications() { debug.logV(TAG, "clearNotifications()"); String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); mNotificationManager.cancel(NOTIF_ID); }
From source file:edu.princeton.jrpalmer.asmlibrary.Settings.java
public void cancelNotification(Context context) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(Util.PRO_CONVERSION_NOTIFICATION); }
From source file:com.vonglasow.michael.satstat.ui.MainActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { StringBuilder messageBuilder = new StringBuilder(); for (int i = 0; i < grantResults.length; i++) if (permissions[i].equals(Manifest.permission.ACCESS_FINE_LOCATION)) { if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(Const.PERM_REQUEST_LOCATION_NOTIFICATION); if (permsRequested[Const.PERM_REQUEST_PHONE_STATE_LISTENER]) { registerPhoneStateListener(); permsRequested[Const.PERM_REQUEST_PHONE_STATE_LISTENER] = false; }//w ww . j ava2s. c o m if (permsRequested[Const.PERM_REQUEST_LOCATION_UPDATES]) { requestLocationUpdates(); permsRequested[Const.PERM_REQUEST_LOCATION_UPDATES] = false; } if (permsRequested[Const.PERM_REQUEST_CELL_INFO]) { if (radioSectionFragment != null) radioSectionFragment.updateCellData(null, null, null); permsRequested[Const.PERM_REQUEST_CELL_INFO] = false; } if (requestCode == Const.PERM_REQUEST_REFRESH_AGPS) GpsEventReceiver.refreshAgps(this, false, true); } else if (requestCode == Const.PERM_REQUEST_REFRESH_AGPS) { if (messageBuilder.length() > 0) messageBuilder.append("\n"); messageBuilder.append(getString(R.string.status_perm_refresh_agps)); Log.w(TAG, "Location permission not granted, cannot update AGPS data"); } else { if (messageBuilder.length() > 0) messageBuilder.append("\n"); messageBuilder.append(getString(R.string.status_perm_location)); Log.w(TAG, "ACCESS_FINE_LOCATION permission not granted. Location and cell info will not be available."); } // if grantResults[i] } else if (permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { if (permsRequested[Const.PERM_REQUEST_OFFLINE_MAP] && (mapSectionFragment != null)) { mapSectionFragment.onMapSourceChanged(); permsRequested[Const.PERM_REQUEST_OFFLINE_MAP] = false; } } else { if (messageBuilder.length() > 0) messageBuilder.append("\n"); messageBuilder.append(getString(R.string.status_perm_offline_map)); Log.w(TAG, "WRITE_EXTERNAL_STORAGE permission not granted. Offline map will not be available."); } } // if permissions[i].equals() // for i String message = messageBuilder.toString(); if (!message.isEmpty()) { int length = (message.contains("\n")) ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT; Toast.makeText(this, message, length).show(); } }
From source file:net.ben.subsonic.androidapp.util.Util.java
public static void showErrorNotification(final Context context, Handler handler, String title, Exception error) {/*from w ww .ja v a2 s .co m*/ final NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); StringBuilder text = new StringBuilder(); if (error.getMessage() != null) { text.append(error.getMessage()).append(" ("); } text.append(error.getClass().getSimpleName()); if (error.getMessage() != null) { text.append(")"); } // Set the icon, scrolling text and timestamp final Notification notification = new Notification(android.R.drawable.stat_sys_warning, title, System.currentTimeMillis()); notification.flags |= Notification.FLAG_AUTO_CANCEL; // The PendingIntent to launch our activity if the user selects this notification Intent intent = new Intent(context, ErrorActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Constants.INTENT_EXTRA_NAME_ERROR, title + ".\n\n" + text); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, text, contentIntent); // Send the notification. handler.post(new Runnable() { @Override public void run() { notificationManager.cancel(Constants.NOTIFICATION_ID_ERROR); notificationManager.notify(Constants.NOTIFICATION_ID_ERROR, notification); } }); }
From source file:com.yahala.ui.LaunchActivity.java
@Override protected void onResume() { super.onResume(); XMPPManager.foreground = true;//from w w w .j av a 2 s. co m if (notificationView == null && getLayoutInflater() != null) { notificationView = (NotificationView) getLayoutInflater().inflate(R.layout.notification_layout, null); } if (XMPPManager.getInstance().connectionState == ConnectionState.ONLINE) { connectionStatusLayout.setVisibility(View.GONE); connectionStatusLayout.setAlpha(0); } fixLayout(); // checkForCrashes(); // checkForUpdates(); ConnectionsManager.resetLastPauseTime(); supportInvalidateOptionsMenu(); updateActionBar(); try { NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(1); MessagesController.getInstance().currentPushMessage = null; } catch (Exception e) { FileLog.e("Yahala", e); } if (XMPPManager.getInstance().isConnected()) { /*XmppManager.getInstance().mCurrentRetryCount = 0; XmppManager.getInstance().maybeStartReconnect(); checkConnectionState();*/ FileLog.e("onResume()", XMPPManager.getInstance().getStatusName(UserConfig.presence) + ""); if (UserConfig.presence == -1) { XMPPManager.getInstance().setPresence(XMPPManager.Available, false); } else { XMPPManager.getInstance().setPresence(UserConfig.presence, false); } } else { //XmppManager.getInstance().presenceType = XmppManager.Available; if (ConnectivityManagerUtil.hasDataConnection(ApplicationLoader.applicationContext)) { XMPPManager.getInstance().mCurrentRetryCount = 0; XMPPManager.getInstance().maybeStartReconnect(); checkConnectionState(); } } }