Java Code Examples for android.support.v4.app.NotificationManagerCompat#cancel()

The following examples show how to use android.support.v4.app.NotificationManagerCompat#cancel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaNotificationManager.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
void clearNotification() {
    mThrottler.clearPendingNotifications();
    if (mMediaNotificationInfo == null) return;

    NotificationManagerCompat manager = NotificationManagerCompat.from(getContext());
    manager.cancel(mMediaNotificationInfo.id);

    if (mMediaSession != null) {
        mMediaSession.setCallback(null);
        mMediaSession.setActive(false);
        mMediaSession.release();
        mMediaSession = null;
    }
    if (mService != null) {
        getContext().stopService(createIntent());
    }
    mMediaNotificationInfo = null;
    mNotificationBuilder = null;
}
 
Example 2
Source File: Notifications.java    From HAPP with GNU General Public License v3.0 6 votes vote down vote up
public static void clear(String what){
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(MainApp.instance());

    switch (what){
        case "updateCard":
            notificationManager.cancel(UPDATE_CARD);
            break;
        case "newTemp":
            notificationManager.cancel(NEW_TEMP);
            break;
        case "INSULIN_UPDATE":
            notificationManager.cancel(INSULIN_UPDATE);
            break;
    }

}
 
Example 3
Source File: TimerService.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
private void removeAlarm() {
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from( this );
    notificationManager.cancel( 1 );

    AlarmManager alarmManager = (AlarmManager) getSystemService( Context.ALARM_SERVICE );

    Intent intent = new Intent( IterationActivity.ACTION_SHOW_ALARM, null, this, TimerService.class );
    PendingIntent pendingIntent = PendingIntent.getService( this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT );

    alarmManager.cancel( pendingIntent );

    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = pref.edit();
    editor.putLong( IterationActivity.SAVED_STATE_SELECTED_DURATION, 0 );
    editor.apply();
}
 
Example 4
Source File: PlumbleReconnectNotification.java    From Plumble with GNU General Public License v3.0 5 votes vote down vote up
public void hide() {
    try {
        mContext.unregisterReceiver(mNotificationReceiver);
    } catch (IllegalArgumentException e) {
        // Thrown if receiver is not registered.
        e.printStackTrace();
    }
    NotificationManagerCompat nmc = NotificationManagerCompat.from(mContext);
    nmc.cancel(NOTIFICATION_ID);
}
 
Example 5
Source File: MediaNotificationManager.java    From delion with Apache License 2.0 5 votes vote down vote up
private void clearNotification() {
    if (mMediaNotificationInfo == null) return;

    NotificationManagerCompat manager = NotificationManagerCompat.from(mContext);
    manager.cancel(mMediaNotificationInfo.id);

    if (mMediaSession != null) {
        mMediaSession.setCallback(null);
        mMediaSession.setActive(false);
        mMediaSession.release();
        mMediaSession = null;
    }
    mContext.stopService(createIntent(mContext));
    mMediaNotificationInfo = null;
}
 
Example 6
Source File: MediaNotificationManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void clearNotification() {
    if (mMediaNotificationInfo == null) return;

    NotificationManagerCompat manager = NotificationManagerCompat.from(mContext);
    manager.cancel(mMediaNotificationInfo.id);

    if (mMediaSession != null) {
        mMediaSession.setCallback(null);
        mMediaSession.setActive(false);
        mMediaSession.release();
        mMediaSession = null;
    }
    mContext.stopService(createIntent(mContext));
    mMediaNotificationInfo = null;
}
 
Example 7
Source File: NotificationService.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
private void cancel(String tag, int id) {
    final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService);
    try {
        notificationManager.cancel(tag, id);
    } catch (RuntimeException e) {
        Log.d(Config.LOGTAG, "unable to cancel notification", e);
    }
}
 
Example 8
Source File: NotificationService.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public void cancel(int id) {
    final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService);
    try {
        notificationManager.cancel(id);
    } catch (RuntimeException e) {
        Log.d(Config.LOGTAG, "unable to cancel notification", e);
    }
}
 
Example 9
Source File: SongBroadCast.java    From YTPlayer with GNU General Public License v3.0 5 votes vote down vote up
public void disableContext(Context context) {
    NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
    notificationManagerCompat.cancel(1);
    if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O) {
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.deleteNotificationChannel("channel_01");
    }
    Process.killProcess(Process.myPid());
}
 
Example 10
Source File: NotificationService.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public static void cancelIncomingCallNotification(final Context context) {
    final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
    try {
        notificationManager.cancel(INCOMING_CALL_NOTIFICATION_ID);
    } catch (RuntimeException e) {
        Log.d(Config.LOGTAG, "unable to cancel incoming call notification after crash", e);
    }
}
 
Example 11
Source File: IterationActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
private void setupTimer( long duration ) {
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from( this );
    notificationManager.cancel( 1 );
    notificationManager.notify( 1, buildNotification( duration ) );
    registerAlarmManager(duration);
    finish();
}
 
Example 12
Source File: OngoingNotificationListenerService.java    From WearOngoingNotificationSample with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals(Constants.PATH_DISMISS)) {
        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.cancel(NOTIFICATION_ID);
    }
}
 
Example 13
Source File: TimerNotificationService.java    From AndroidWearable-Samples with Apache License 2.0 4 votes vote down vote up
private void cancelCountdownNotification() {
    NotificationManagerCompat notifyMgr = NotificationManagerCompat.from(this);
    notifyMgr.cancel(Constants.NOTIFICATION_TIMER_COUNTDOWN);
}
 
Example 14
Source File: PlumbleMessageNotification.java    From Plumble with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Dismisses the unread messages notification, marking all messages read.
 */
public void dismiss() {
    mUnreadMessages.clear();
    final NotificationManagerCompat manager = NotificationManagerCompat.from(mContext);
    manager.cancel(NOTIFICATION_ID);
}
 
Example 15
Source File: NotifyHelper.java    From NotificationHelper with Apache License 2.0 4 votes vote down vote up
public void cancel(int id) {
    NotificationManagerCompat nm = NotificationManagerCompat.from(context);
    nm.cancel(id);
}
 
Example 16
Source File: AlarmNotifications.java    From SuntimesWidget with GNU General Public License v3.0 4 votes vote down vote up
public static void dismissNotification(Context context, int notificationID)
{
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
    notificationManager.cancel(ALARM_NOTIFICATION_TAG, notificationID);
}
 
Example 17
Source File: LocalNotificationManager.java    From OsmGo with MIT License 4 votes vote down vote up
private void dismissVisibleNotification(int notificationId) {
  NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this.context);
  notificationManager.cancel(notificationId);
}
 
Example 18
Source File: AndroidNotification.java    From QtAndroidTools with MIT License 4 votes vote down vote up
public void cancel()
{
    NotificationManagerCompat Manager = NotificationManagerCompat.from(mActivityInstance);
    Manager.cancel(mNotificationId);
}
 
Example 19
Source File: SetTimerActivity.java    From AndroidWearable-Samples with Apache License 2.0 2 votes vote down vote up
/**
 * Cancels an old countdown and deletes the dataItem.
 *
 * @param notifyMgr the notification manager.
 */
private void cancelCountdown(NotificationManagerCompat notifyMgr) {
    notifyMgr.cancel(Constants.NOTIFICATION_TIMER_EXPIRED);
}