NotificationManager cancelAll - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for NotificationManager cancelAll method.

This code example shows how to use the following methods:cancelAll, notify
        assertNull(shadowOf(notificationManager).getNotification("a tag", 1));
    } 
 
    @Test 
    public void testCancelAll() throws Exception { 
        notificationManager.notify(1, notification1);
        notificationManager.notify(31, notification2);
        notificationManager.cancelAll();
 
        assertEquals(0, shadowOf(notificationManager).size());
        assertNull(shadowOf(notificationManager).getNotification(null, 1));
        assertNull(shadowOf(notificationManager).getNotification(null, 31));
    } 
} 
8
CodeRank
This code example shows how to use the following methods:cancelAll
 
    /** 
     * Removes all Notifications from the status bar. 
     */ 
    public void clearAllNotifications() { 
        mNotificationManager.cancelAll();
    } 
 
    /** 
     * Called when a notification is clicked. 
     * @param intent The new Intent passed from the notification. 
     */ 
    @Override 
    public void onNewIntent(Intent intent) {
        // The incoming Intent may or may not have been for a notification. 
        String tag = intent.getStringExtra("notificationTag");
        if (tag != null) {
        	 this.webView.sendJavascript("window.Notification.callOnclickByTag('"+ tag + "')");
        } 
    } 
9
CodeRank
This code example shows how to use the following methods:cancelAll
    } 
 
    @Override 
    public void onDestroy() { 
        unregisterReceiver(mStateReceiver);
        mNotificationManager.cancelAll();
        // if (mPreferences.getBoolean(PREFERENCE_KEY_AUTO_REFRESH, false)) { 
        // Auto refresh enabled, so I will try to start service after it was 
        // stopped. 
        // startService(new Intent(INTENT_ACTION_SERVICE)); 
        // } 
        mIsRunning = false;
        super.onDestroy(); 
    } 
 
    public void shutdownService() { 
        // Auto refresh is enabled, so this service cannot be shut down. 
        /* 
         * if (mPreferences.getBoolean(PREFERENCE_KEY_AUTO_REFRESH, false)) 
         * return; if (!mAsyncTaskManager.hasActivatedTask()) { stopSelf(); } 
6
CodeRank
This code example shows how to use the following methods:cancelAll
        mNotificationManager.cancel((int) id);
    } 
 
    @Override 
    public void cancelAllNotifications() { 
        mNotificationManager.cancelAll();
    } 
 
    @Override 
    public void startThread(Thread thread) {
        thread.start();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:cancel, cancelAll
 
 
    public void shutdown () { 
        // get rid of the notification bar items.  
        try { 
            mNotificationManager.cancel(VOYAGER_NOTIFY_ID_CHECKENG);
            mNotificationManager.cancelAll();
            mNotificationCheckEngine = null;
        } catch (Exception e) {
        	msg ("Exception during shutdown: " + e.getMessage());
        } 
 
    } 
 
     
    private void msg (String messg) {
    	Log.d("NotificationHelper",messg);
    } 
     
} // end of NotificationHelper class.  
6
CodeRank
This code example shows how to use the following methods:cancelAll
This code example shows how to use the following methods:cancelAll
    public void onDestroy() { 
        Log.v(TAG, "onDestroy");
 
        // remove the notification 
        NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        nm.cancelAll();
        stopForeground(true);
 
        // we where asked to stop running, so make sure the user gets back his 
        // status bar 
        Device device = Device.getInstance();
        device.showSystembar(true);
    } 
 
    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.v(TAG, "onStartCommand");
 
        // we just have to start service once, not keep restarting 
        return Service.START_NOT_STICKY;
6
CodeRank
This code example shows how to use the following methods:cancelAll
 
    private void clearNotification(Context context) {
        Log.d(TAG, "Clearing the notifications");
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager nm = (NotificationManager) context.getSystemService(ns);
        nm.cancelAll();
        Log.d(TAG, "Cleared notification");
    } 
} 
5
CodeRank
This code example shows how to use the following methods:cancelAll
	 * @return void. 
	 */ 
	public static void clearAll(Context context) {
		NotificationManager myNM = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		myNM.cancelAll();
	} 
 
	/** 
	 * Clear a running notification. 
	 *  
	 * @param Context 
	 *            context - The context of the calling activity. 
	 * @return void 
	 */ 
	public static void clearNotify(Context context) {
		NotificationManager myNM = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		myNM.cancel(NOTIFY_RUNNING);
	} 
5
CodeRank
This code example shows how to use the following methods:cancelAll
    		p = new PreferenceService(this);
 
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
        // Cancel the persistent notification. 
    	mNotificationManager.cancelAll();
 
        // Tell the user we stopped. 
        if (p.isToastNotify())
        	Toast.makeText(this, "adbdSecure stopped", Toast.LENGTH_SHORT).show();
         
        if (mReceiver != null)
        	unregisterReceiver(mReceiver);
         
        this.stopForeground(false);
    } 
     
	@Override 
	public int onStartCommand(Intent intent, int flags, int startId) {
		 
5
CodeRank

Related NotificationManager cancelAll Questions & Answers:

cancelAll Method Overview
Cancel all previously shown notifications.
See Code Examples for other Android NotificationManager Methods: