Example usage for android.app NotificationManager cancel

List of usage examples for android.app NotificationManager cancel

Introduction

In this page you can find the example usage for android.app NotificationManager cancel.

Prototype

public void cancel(int id) 

Source Link

Document

Cancel a previously shown notification.

Usage

From source file:com.nkc.education.service.NotificationHelper.java

/**
 * Cancels an existing notification, if user modified the task. Make the
 * actual call from TaskAlarm.cancelNotification(Context, int)
 *
 * @param context/*from w w w.  ja v a2s .c om*/
 * @param taskID
 */
public void cancelNotification(Context context, int taskID) {
    NotificationManager notificationManager = getNotificationManager(context);
    notificationManager.cancel(taskID);
}

From source file:org.godotengine.godot.storage.BaseTaskService.java

/**
 * Dismiss the progress notification.//from ww w  . j av  a  2  s  .c om
 */
protected void dismissProgressNotification() {
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    manager.cancel(PROGRESS_NOTIFICATION_ID);
}

From source file:com.klinker.android.twitter.activities.compose.NotificationDMCompose.java

@Override
public void setUpLayout() {
    super.setUpLayout();

    // mark the messages as read here
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);

    sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit();

    notiId = 1;/*from  www .  j  a v a  2  s.  c  o m*/
    replyText = sharedPrefs.getString("from_notification_text", "");
    sharedPrefs.edit().putString("from_notification_text", "").commit();

    contactEntry.setText(sharedPrefs.getString("from_notification", "").replace(" ", ""));
    reply.requestFocus();

    // try from android wear device
    CharSequence voiceReply = getVoiceReply(getIntent());
    if (voiceReply != null) {
        if (!voiceReply.equals("")) {
            // set the text
            reply.setText(voiceReply);

            // send the message
            doneClick();

            finish();
        }
    }
}

From source file:io.github.minime89.passbeam.hooks.NotificationListener.java

/**
 * Hide the notification.//  w  w w.j  av  a2 s.c  o m
 *
 * @param context The {@link Context}.
 */
public void hide(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(NOTIFICATION_ID);
}

From source file:com.uriel.myapplication.MyGcmListenerService.java

public void cancelNotification(int notificationId) {

    if (Context.NOTIFICATION_SERVICE != null) {
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager nMgr = (NotificationManager) getApplicationContext().getSystemService(ns);
        nMgr.cancel(notificationId);
    }/*w  ww.  ja  va 2 s.  c  o m*/
}

From source file:de.dreier.mytargets.WearableListener.java

private void showNotification(NotificationInfo info) {

    // Build the intent to display our custom notification
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.putExtra(MainActivity.EXTRA_ROUND, Parcels.wrap(info.round));
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    // Build activity page
    Notification page = new Notification.Builder(this).setSmallIcon(R.mipmap.ic_launcher)
            .extend(new Notification.WearableExtender()
                    .setCustomSizePreset(Notification.WearableExtender.SIZE_FULL_SCREEN)
                    .setDisplayIntent(pendingIntent))
            .build();/*  w  w w . j  a v a2s  .  c  o m*/

    // Create the ongoing notification
    Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.wear_bg);
    Notification.Builder notificationBuilder = new Notification.Builder(this).setContentTitle(info.title)
            .setContentText(info.text).setSmallIcon(R.mipmap.ic_launcher).setOngoing(true)
            .extend(new Notification.WearableExtender().addPage(page).setBackground(image));

    // Build the notification and show it
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.cancel(NOTIFICATION_ID);
    notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
}

From source file:com.luan.thermospy.android.core.NotificationHandler.java

public void cancel(Context c) {
    NotificationManager mNotificationManager = (NotificationManager) c
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(mId);
}

From source file:codes.simen.l50notifications.ReminderService.java

@Override
public void onDestroy() {
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.cancel(NOTIFICATION_ID);
    super.onDestroy();
}

From source file:com.emsitel.emsivoz.MainActivity.java

public void Verifica() {
    if (!verificaConexion(this)) {
        Log.e("Comprueba tu conexin a internet");
        NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        nManager.cancel(RUNNING_NOTIFICATION_ID);
    } else {//from  w  ww  .  j  a  v a  2  s. c  o m
        Log.i("Conectado a internet");
        NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        mRunningNotification = createRunningNotification(R.string.sip_active_title, R.string.sip_active_content,
                R.string.sip_active_ticker);
        nManager.notify(RUNNING_NOTIFICATION_ID, mRunningNotification);
        startForeground(RUNNING_NOTIFICATION_ID, mRunningNotification);
    }
}

From source file:com.kevalpatel.sample.MainActivity.java

@Override
public void onScreenMonitoringStop() {
    NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mNotifyMgr.cancel(NOTIFICATION_ID);
}