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.chen.mail.utils.NotificationUtils.java

/**
 * Clears all notifications for the specified account.
 */// ww  w . j a  v a  2 s .  c om
public static void clearAccountNotifications(final Context context, final android.accounts.Account account) {
    LogUtils.v(LOG_TAG, "Clearing all notifications for %s", account);
    final NotificationMap notificationMap = getNotificationMap(context);

    // Find all NotificationKeys for this account
    final ImmutableList.Builder<NotificationKey> keyBuilder = ImmutableList.builder();

    for (final NotificationKey key : notificationMap.keySet()) {
        if (account.equals(key.account.getAccountManagerAccount())) {
            keyBuilder.add(key);
        }
    }

    final List<NotificationKey> notificationKeys = keyBuilder.build();

    final NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    for (final NotificationKey notificationKey : notificationKeys) {
        final Folder folder = notificationKey.folder;
        notificationManager.cancel(getNotificationId(account, folder));
        notificationMap.remove(notificationKey);
    }

    notificationMap.saveNotificationMap(context);
}

From source file:com.aengbee.android.leanback.ui.VideoDetailsFragment.java

private void removeNotification(int notificationId) {
    if (notificationId != NO_NOTIFICATION) {
        NotificationManager notificationManager = (NotificationManager) getActivity()
                .getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(notificationId);
    }//w  w  w .j  av  a 2 s.  c  o  m
}

From source file:com.smedic.tubtub.BackgroundAudioService.java

/**
 * Initializes media sessions and receives media events
 *//*from w  w w .j a v a 2 s.  c  o  m*/
private void initMediaSessions() {
    PendingIntent buttonReceiverIntent = PendingIntent.getBroadcast(getApplicationContext(), 0,
            new Intent(Intent.ACTION_MEDIA_BUTTON), PendingIntent.FLAG_UPDATE_CURRENT);

    mSession = new MediaSessionCompat(getApplicationContext(), "simple player session", null,
            buttonReceiverIntent);

    try {
        mController = new MediaControllerCompat(getApplicationContext(), mSession.getSessionToken());

        mSession.setCallback(new MediaSessionCompat.Callback() {
            @Override
            public void onPlay() {
                super.onPlay();
                buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE));
            }

            @Override
            public void onPause() {

                super.onPause();
                pauseVideo();
                buildNotification(generateAction(android.R.drawable.ic_media_play, "Play", ACTION_PLAY));
            }

            @Override
            public void onSkipToNext() {
                super.onSkipToNext();
                playNext();
                buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE));
            }

            @Override
            public void onSkipToPrevious() {
                super.onSkipToPrevious();
                playPrevious();
                buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE));
            }

            @Override
            public void onStop() {
                super.onStop();
                stopPlayer();
                //remove notification and stop service
                NotificationManager notificationManager = (NotificationManager) getApplicationContext()
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                notificationManager.cancel(1);
                Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class);
                stopService(intent);
            }

            @Override
            public void onSetRating(RatingCompat rating) {
                super.onSetRating(rating);
            }
        });
    } catch (RemoteException re) {
        re.printStackTrace();
    }
}

From source file:fi.iki.murgo.irssinotifier.SettingsActivity.java

private void handleColorPicker() {
    Preference colorPickerPref = findPreference("PickCustomLightColor");
    colorPickerPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override/*from www .  j av  a 2s. co m*/
        public boolean onPreferenceClick(final Preference preference) {
            final Context ctx = SettingsActivity.this;

            final Preferences preferences = new Preferences(ctx);
            final int color = preferences.getCustomLightColor();

            NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
            builder.setSmallIcon(R.drawable.notification_icon);
            builder.setTicker("Preview selected color");
            builder.setAutoCancel(false);
            builder.setOngoing(false);
            builder.setContentText("Wait for the screen to turn off to see selected light color in action");
            builder.setContentTitle("Preview light color");
            builder.setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0));
            builder.setLights(color, 300, 5000);

            final Notification notification = builder.build();
            final NotificationManager notificationManager = (NotificationManager) ctx
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.notify(666, notification);

            final AmbilWarnaDialog dialog = new AmbilWarnaDialog(ctx, color,
                    new AmbilWarnaDialog.OnAmbilWarnaListener() {
                        @Override
                        public void onCancel(AmbilWarnaDialog dialog) {
                            notificationManager.cancel(666);
                        }

                        @Override
                        public void onOk(AmbilWarnaDialog dialog, int color) {
                            notificationManager.cancel(666);
                            preferences.setCustomLightColor(color);
                        }

                        @Override
                        public void onColorChanged(AmbilWarnaDialog dialog, int color) {
                            notification.ledARGB = color;
                            notificationManager.notify(666, notification);
                        }
                    });

            dialog.show();

            return true;
        }
    });
}

From source file:com.sean.takeastand.alarmprocess.AlarmService.java

private void cancelNotification() {
    Log.i(TAG, "Notification removed");
    NotificationManager notificationManager = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(R.integer.AlarmNotificationID);
}

From source file:saphion.fragment.alarm.alert.AlarmAlertReceiver.java

@SuppressWarnings("deprecation")
@Override//from  ww w .  j  a  v  a2 s. co m
public void onReceive(final Context context, final Intent intent) {
    String action = intent.getAction();
    int pos = intent.getIntExtra(PreferenceHelper.BAT_VALS, 0);
    level = intent.getIntExtra(PreferenceHelper.CURR_RING, 72);

    //Log.Toast(context, level + " in receiver", Toast.LENGTH_LONG);
    // int id = intent.getIntExtra(Intents.EXTRA_ID, -1);

    if (action.equals(Intents.ALARM_ALERT_ACTION)) {
        /* Close dialogs and window shade */
        Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        context.sendBroadcast(closeDialogs);

        // Decide which activity to start based on the state of the
        // keyguard.
        /*
         * KeyguardManager km = (KeyguardManager)
         * context.getSystemService(Context.KEYGUARD_SERVICE); if
         * (km.inKeyguardRestrictedInputMode()) { // Use the full screen
         * activity for security. c = AlarmAlertFullScreen.class; }
         */

        // Trigger a notification that, when clicked, will show the alarm
        // alert
        // dialog. No need to check for fullscreen since this will always be
        // launched from a user action.

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            Intent notify = new Intent(context, saphion.fragments.alarm.AlarmAlert.class);
            notify.putExtra(PreferenceHelper.BAT_VALS, pos);
            PendingIntent pendingNotify = PendingIntent.getActivity(context, ID, notify, 0);

            // Alarm alarm = AlarmsManager.getAlarmsManager().getAlarm(id);
            Notification n = new Notification(R.drawable.stat_notify_alarm, "abc", System.currentTimeMillis());
            n.setLatestEventInfo(context, "Battery Alarm", "Battery Level is " + level, pendingNotify);
            n.flags |= Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONGOING_EVENT;
            n.defaults |= Notification.DEFAULT_LIGHTS;

            // NEW: Embed the full-screen UI here. The notification manager
            // will // take care of displaying it if it's OK to do so.
            Intent alarmAlert = new Intent(context, saphion.fragments.alarm.AlarmAlert.class);
            alarmAlert.putExtra(PreferenceHelper.CURR_RING, level);
            alarmAlert.putExtra(PreferenceHelper.BAT_VALS, pos);
            alarmAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
            n.fullScreenIntent = PendingIntent.getActivity(context, ID, alarmAlert, 0);

            // Send the notification using the alarm id to easily identify
            // the // correct notification.
            NotificationManager nm = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            // Log.Toast(context, "Recieved", Toast.LENGTH_LONG);
            // mNotificationManager.notify(ID, builder.build());
            nm.notify(ID, n);
        } else {
            // Log.Toast(context, "Recieved", Toast.LENGTH_LONG);
            newMethod(context, pos);
        }

    } else if (action.equals(Intents.ALARM_DISMISS_ACTION)) {
        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        nm.cancel(ID);
    }
}

From source file:com.z3r0byte.magistify.Services.OldBackgroundService.java

private void notifyAppointmentTimer() {
    Log.d(TAG, "notifyAppoinytmentTimer: Starting appointment timer");
    TimerTask notificationTask = new TimerTask() {
        @Override//from  w  w  w .jav a  2s .c  om
        public void run() {

            Gson gson = new Gson();
            Appointment[] appointments = calendarDB.getNotificationAppointments();
            Log.d(TAG, "AppointmentNotifications: amount of appointments that should be shown: "
                    + appointments.length);
            previousAppointment = configUtil.getString("previous_appointment");
            if (appointments.length >= 1) {
                Appointment appointment = appointments[0];
                if (!gson.toJson(appointment).equals(previousAppointment) && isCandidate(appointment)) {
                    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                            getApplicationContext());
                    mBuilder.setSmallIcon(R.drawable.ic_appointment);

                    if (appointment.startDate != null) {
                        String time = DateUtils.formatDate(appointment.startDate, "HH:mm");
                        mBuilder.setContentTitle("Volgende afspraak (" + time + ")");
                    } else {
                        mBuilder.setContentTitle("Volgende afspraak:");
                    }
                    mBuilder.setContentText(appointment.description + " in " + appointment.location);
                    mBuilder.setAutoCancel(true);
                    mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);

                    Intent resultIntent = new Intent(getApplicationContext(), AppointmentActivity.class);
                    TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext());
                    stackBuilder.addParentStack(AppointmentActivity.class);
                    stackBuilder.addNextIntent(resultIntent);
                    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                            PendingIntent.FLAG_UPDATE_CURRENT);
                    mBuilder.setContentIntent(resultPendingIntent);

                    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                            Context.NOTIFICATION_SERVICE);
                    mNotificationManager.notify(9991, mBuilder.build());

                    previousAppointment = gson.toJson(appointment);
                    configUtil.setString("previous_appointment", previousAppointment);
                }
            } else {
                NotificationManager notifManager = (NotificationManager) getSystemService(
                        Context.NOTIFICATION_SERVICE);
                notifManager.cancel(9991);
            }
        }
    };
    timer.schedule(notificationTask, 20000, 30 * 1000);
}

From source file:com.z3r0byte.magistify.Services.OldBackgroundService.java

private void notifyAppointmentChangedTimer() {
    Log.d(TAG, "notifyAppoinytmentTimer: Starting notify appointmentchange timer");
    TimerTask notificationTask = new TimerTask() {
        @Override/*from   w w  w . j  a  v a  2 s. c o m*/
        public void run() {

            ScheduleChangeDB scheduleChangeDB = new ScheduleChangeDB(getApplicationContext());

            Appointment[] appointments = scheduleChangeDB.getNotificationAppointments();
            previousChangedAppointment = configUtil.getString("previous_changed_appointment");
            if (appointments.length > 0) {
                Appointment appointment = appointments[0];
                if (!appointment.startDateString.equals(previousChangedAppointment)) {
                    String content;
                    if (appointment.description != null && !appointment.description.equalsIgnoreCase("null")) {
                        content = appointment.description;
                    } else {
                        content = "De les is uitgevallen!";
                    }

                    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                            getApplicationContext());
                    mBuilder.setSmallIcon(R.drawable.ic_schedule_change);

                    mBuilder.setContentTitle("Let op! De volgende les is gewijzigd!");
                    mBuilder.setContentText(content);
                    mBuilder.setAutoCancel(true);
                    mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
                    mBuilder.setDefaults(Notification.DEFAULT_ALL);

                    Intent resultIntent = new Intent(getApplicationContext(), ScheduleChangeActivity.class);
                    TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext());
                    stackBuilder.addParentStack(ScheduleChangeActivity.class);
                    stackBuilder.addNextIntent(resultIntent);
                    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
                            PendingIntent.FLAG_UPDATE_CURRENT);
                    mBuilder.setContentIntent(resultPendingIntent);

                    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                            Context.NOTIFICATION_SERVICE);
                    mNotificationManager.notify(9994, mBuilder.build());

                    previousChangedAppointment = appointment.startDateString;
                    configUtil.setString("previous_changed_appointment", appointment.startDateString);
                }
            } else {
                NotificationManager notifManager = (NotificationManager) getSystemService(
                        Context.NOTIFICATION_SERVICE);
                notifManager.cancel(9994);
            }
        }
    };
    timer.schedule(notificationTask, 20000, 30 * 1000);
}

From source file:net.kourlas.voipms_sms.activities.ConversationActivity.java

@Override
protected void onResume() {
    super.onResume();
    ActivityMonitor.getInstance().setCurrentActivity(this);

    Integer id = Notifications.getInstance(getApplicationContext()).getNotificationIds().get(contact);
    if (id != null) {
        NotificationManager notificationManager = (NotificationManager) getApplicationContext()
                .getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(id);
    }//from  w w  w.j  av  a 2 s. c o m

    markConversationAsRead();

    adapter.refresh();
}

From source file:org.durka.hallmonitor.CoreReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED) || intent.getAction().equals(QUICKBOOT_POWERON)
            || intent.getAction().equals(HTC_QUICKBOOT_POWERON)) {
        Log.d(LOG_TAG + ".boot", "Boot called.");
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        if (prefs.getBoolean("pref_enabled", false)) {
            Intent mIntent = new Intent(context, CoreService.class);
            context.startService(mIntent);
        }/*  w  ww .  j  av  a 2 s .c  o  m*/
    }

    if (CoreStateManager.getInitialized()) {
        localContext = CoreStateManager.getContext();
        mStateManager = ((CoreApp) localContext).getStateManager();
    } else {
        return;
    }

    if (!mStateManager.getPreference().getBoolean("pref_enabled", false)) {
        return;
    }

    mStateManager.acquireCPUGlobal();

    if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {

        Log.d(LOG_TAG + ".screen", "Screen on event received.");

        if (mStateManager.getCoverClosed()) {
            Log.d(LOG_TAG + ".screen", "Cover is closed, display Default Activity.");
            mStateManager.setBlackScreenTime(0);
            Intent mIntent = new Intent(localContext, CoreService.class);
            mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_LAUNCH_ACTIVITY);
            mStateManager.sendToCoreService(mIntent);
        } else {
            // Log.d(LOG_TAG + ".screen",
            // "Cover is open, free everything.");
            // mStateManager.freeDevice();
            Log.d(LOG_TAG + ".screen", "Cover is open, send to background.");
            Intent stbDAIntent = new Intent(CoreApp.DA_ACTION_SEND_TO_BACKGROUND);
            LocalBroadcastManager.getInstance(localContext).sendBroadcastSync(stbDAIntent);
        }

    } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
        Log.d(LOG_TAG + ".screen", "Screen off event received.");
        // mStateManager.freeDevice();

    } else if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
        Intent batteryDAIntent = new Intent(CoreApp.DA_ACTION_BATTERY_REFRESH);
        LocalBroadcastManager.getInstance(localContext).sendBroadcastSync(batteryDAIntent);

        Intent mIntent = new Intent(localContext, CoreService.class);
        mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_WAKEUP_DEVICE);
        mStateManager.sendToCoreService(mIntent);

    } else if (intent.getAction().equals(Intent.ACTION_POWER_DISCONNECTED)) {
        Intent batteryDAIntent = new Intent(CoreApp.DA_ACTION_BATTERY_REFRESH);
        LocalBroadcastManager.getInstance(localContext).sendBroadcastSync(batteryDAIntent);

        Intent mIntent = new Intent(localContext, CoreService.class);
        mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_WAKEUP_DEVICE);
        mStateManager.sendToCoreService(mIntent);

    } else if (intent.getAction().equals(ALARM_ALERT_ACTION)) {

        Log.d(LOG_TAG + ".alarm", "Alarm on event received.");

        // only take action if alarm controls are enabled
        if (mStateManager.getPreference().getBoolean("pref_alarm_controls", false)) {

            Log.d(LOG_TAG + ".alarm", "Alarm controls are enabled, taking action.");
            mStateManager.setAlarmFiring(true);

            Intent mIntent = new Intent(localContext, CoreService.class);
            mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_INCOMMING_ALARM);
            mStateManager.sendToCoreService(mIntent);
        } else {
            Log.d(LOG_TAG + ".alarm", "Alarm controls are not enabled.");
        }

    } else if (intent.getAction().equals(ALARM_DONE_ACTION)) {

        Log.d(LOG_TAG + ".alarm", "Alarm done event received.");

        // only take action if alarm controls are enabled
        if (mStateManager.getPreference().getBoolean("pref_alarm_controls", false)) {
            Log.d(mStateManager.getPreference() + ".alarm", "alarm is over, cleaning up");
            mStateManager.setAlarmFiring(false);

            if (mStateManager.getCoverClosed()) {
                Intent mIntent = new Intent(localContext, CoreService.class);
                mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_LAUNCH_ACTIVITY);
                mStateManager.sendToCoreService(mIntent);
            }
        }
    } else if (intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {

        if (mStateManager.getPreference().getBoolean("pref_phone_controls", false)) {
            String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
            Log.d(LOG_TAG + ".phone", "phone state changed to " + state);
            if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                Intent mIntent;
                mStateManager.setPhoneRinging(true);
                mStateManager.setCallFrom(intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER));
                Log.d(LOG_TAG, "call from " + mStateManager.getCallFrom());
                mIntent = new Intent(localContext, CoreService.class);
                mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_INCOMMING_CALL);
                mStateManager.sendToCoreService(mIntent);
            } else if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
                Intent mIntent;
                mStateManager.setPhoneRinging(false);
                Log.d(LOG_TAG, "call is over, cleaning up");
                if (mStateManager.getCoverClosed()) {
                    mIntent = new Intent(localContext, CoreService.class);
                    mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_LAUNCH_ACTIVITY);
                    mStateManager.sendToCoreService(mIntent);
                }
            } else if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
            }
        } else {
            Log.d(LOG_TAG + ".phone", "phone controls are not enabled");
        }
    } else if (intent.getAction().equals(mStateManager.getActionCover())) {
        int state = intent.getIntExtra(EXTRA_LID_STATE, LID_ABSENT);
        Log.d(LOG_TAG + ".cover", "cover state changed to " + state);
        if (state == LID_CLOSED) {
            Log.d(LOG_TAG + ".cover", "Cover is close, enable Default Activity.");
            mStateManager.setCoverClosed(true);
            Intent mIntent = new Intent(localContext, CoreService.class);
            mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_LAUNCH_ACTIVITY);
            mStateManager.sendToCoreService(mIntent);
        } else if (state == LID_OPEN) {
            // Log.d(LOG_TAG + ".cover",
            // "Cover is open, stopping Default Activity.");
            mStateManager.setCoverClosed(false);
            // mStateManager.freeDevice();
            Log.d(LOG_TAG + ".screen", "Cover is open, send to background.");
            Intent stbDAIntent = new Intent(CoreApp.DA_ACTION_SEND_TO_BACKGROUND);
            LocalBroadcastManager.getInstance(localContext).sendBroadcastSync(stbDAIntent);
            Intent mIntent = new Intent(localContext, CoreService.class);
            mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_WAKEUP_DEVICE);
            mStateManager.sendToCoreService(mIntent);
        }

    } else if (intent.getAction().equals(TORCH_STATE_CHANGED)) {
        if (mStateManager.getPreference().getBoolean("pref_flash_controls", false)) {
            Log.d(LOG_TAG + ".torch", "torch state changed");
            Intent mIntent = new Intent(localContext, CoreService.class);
            mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_TORCH_STATE);
            if (intent.getIntExtra("state", 0) != 0) {
                mIntent.putExtra(CoreApp.CS_EXTRA_STATE, true);
            } else {
                mIntent.putExtra(CoreApp.CS_EXTRA_STATE, false);
            }
            mStateManager.sendToCoreService(mIntent);
        } else {
            Log.d(LOG_TAG + ".torch", "torch controls are not enabled.");
        }

    } else if (intent.getAction().equals(Intent.ACTION_HEADSET_PLUG)) {
        int state = intent.getExtras().getInt("state");
        Log.d(LOG_TAG + ".headset", "headset is " + (state == 0 ? "gone" : "here") + "!");
        Intent mIntent = new Intent(localContext, CoreService.class);
        mIntent.putExtra(CoreApp.CS_EXTRA_TASK, CoreApp.CS_TASK_HEADSET_PLUG);
        mStateManager.sendToCoreService(mIntent);

    } else if (intent.getAction().equals("org.durka.hallmonitor.debug")) {
        Log.d(LOG_TAG + "", "received debug intent");
        // test intent to show/hide a notification
        boolean showhide = false;
        switch (intent.getIntExtra("notif", 0)) {
        case 1:
            showhide = true;
            break;
        case 2:
            showhide = false;
            break;
        }
        if (showhide) {
            Notification.Builder mBuilder = new Notification.Builder(localContext)
                    .setSmallIcon(R.drawable.ic_launcher).setContentTitle("Hall Monitor")
                    .setContentText("Debugging is fun!");

            NotificationManager mNotificationManager = (NotificationManager) localContext
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(42, mBuilder.build());
        } else {
            NotificationManager mNotificationManager = (NotificationManager) localContext
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.cancel(42);
        }
    }
    mStateManager.releaseCPUGlobal();
}