Android NotificationManager - top ranked examples from Open Source projects

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

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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:cancel
     * Cancels a single notification by tag. 
     * 
     * @param tag Notification tag to cancel. 
     */ 
    public void clearNotification(String tag) {
        mNotificationManager.cancel(tag.hashCode());
    } 
 
    /** 
     * 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 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:notify
	            "", System.currentTimeMillis());
	    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
	            mainIntent, 0);
	//TEST 
		notification.setLatestEventInfo(context,"Payment Reminder","Send me to jhaynie@appcelerator.com",contentIntent);
	    manger.notify(1, notification);
	} 
} 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:cancel
    @Override 
    public void onPause() { 
        super.onPause(); 
        Log.d("StatusBarTest", "onPause: Canceling notification id=" + mId);
        NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        nm.cancel(mId);
        finish();
    } 
 
    @SuppressWarnings({"UnusedDeclaration"}) 
    public void dismiss(View v) {
        Log.d("StatusBarTest", "TestAlertActivity.dismiss");
        finish();
    } 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:notify
This code example shows how to use the following methods:notify
                    .setOngoing(false); 
            Notification notification = builder.getNotification();
            final NotificationManager notificationManager = (NotificationManager) getApplicationContext()
                    .getSystemService(NOTIFICATION_SERVICE);
            final int id = tasksNotifications.get(task);
            notificationManager.notify(id, notification);
 
            handler.postDelayed(new Runnable() {
                @Override 
                public void run() { 
                    notificationManager.cancel(id);
                    stopServiceIfTasksAreEnd(task);
                } 
            }, 3000); 
        } 
 
        private void showFailedNotification(final WeiboSendTask task) {
            Notification.Builder builder = new Notification.Builder(SendReplyToCommentService.this)
                    .setTicker(getString(R.string.send_failed))
                    .setContentTitle(getString(R.string.send_faile_click_to_open))
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:notify
	            "", System.currentTimeMillis());
	    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
	            mainIntent, 0);
	//TEST 
		notification.setLatestEventInfo(context,"Payment Reminder","Send me to jhaynie@appcelerator.com",contentIntent);
	    manger.notify(1, notification);
	} 
} 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:notify
            invokeMethod(service, mStartForeground, id, notification);
            return; 
        } 
 
        invokeMethod(service, mSetForeground, Boolean.TRUE);
        mNM.notify(id, notification);
        notifyId = id;
    } 
 
    public void stopForeground(boolean removeNotify) {
        if (mStopForeground != null) {
            invokeMethod(service, mStopForeground, removeNotify);
            return; 
        } 
 
        if (removeNotify) {
            mNM.cancel(notifyId);
        } 
        invokeMethod(service, mSetForeground, Boolean.FALSE);
    } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:cancel, notify
        this.nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
        this.context = context.getApplicationContext(); 
    } 
 
    public void cancelSyncProblemNotification() { 
        nm.cancel(NOTIFICATION_SYNCHRONIZATION_STOPPED_WITH_ERROR); 
        nm.cancel(NOTIFICATION_SYNCHRONIZATION_STOPPED_SPACE_EXCEEDED); 
    } 
 
    void cancelSyncInProgressNotification() { 
        nm.cancel(NOTIFICATION_SYNCHRONIZATION_RUNNING); 
        displaysNotification = false; 
        PL.log("NOTIFICATION: Running: unset", context); 
    } 
 
    public void createCheckReleaseNotesNotification(Uri uri) { 
        Intent i = new Intent(Intent.ACTION_VIEW, uri); 
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
 
        Notification n = new Notification(R.drawable.gen_auto_notification_icon, "NewsRob has been updated", new Date() 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:cancel
     
    mgr.notify(NOTIFY_ME_ID, note);
  } 
   
  public void clearNotification(View v) {
    mgr.cancel(NOTIFY_ME_ID);
  } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android NotificationManager Questions & Answers:

Other Android NotificationManager Examples

30:	        .addAction(R.drawable.icon, "More", pIntent)
31:	        .addAction(R.drawable.icon, "And more", pIntent).build();
32:	    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
33:	    // hide the notification after its selected
34:	    noti.flags |= Notification.FLAG_AUTO_CANCEL;
-
30:	        .addAction(R.drawable.icon, "More", pIntent)
31:	        .addAction(R.drawable.icon, "And more", pIntent).build();
32:	    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
33:	    // hide the notification after its selected
34:	    noti.flags |= Notification.FLAG_AUTO_CANCEL;

Read More

90:	        int icon = R.drawable.ic_launcher;
91:	        long when = System.currentTimeMillis();
92:	        NotificationManager notificationManager = (NotificationManager)
93:	                context.getSystemService(Context.NOTIFICATION_SERVICE);
94:	        Notification notification = new Notification(icon, message, when);
-
90:	        int icon = R.drawable.ic_launcher;
91:	        long when = System.currentTimeMillis();
92:	        NotificationManager notificationManager = (NotificationManager)
93:	                context.getSystemService(Context.NOTIFICATION_SERVICE);
94:	        Notification notification = new Notification(icon, message, when);

Read More

See Code Examples for Android NotificationManager Methods: