Example usage for android.app NotificationManager cancelAll

List of usage examples for android.app NotificationManager cancelAll

Introduction

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

Prototype

public void cancelAll() 

Source Link

Document

Cancel all previously shown notifications.

Usage

From source file:org.ocs.android.agent.service.OCSAgentService.java

public void onDestroy() {
    NotificationManager mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mNM.cancelAll();
}

From source file:com.iniciacomunicacion.devicenotification.DeviceNotification.java

/**
 * Cancels all notifications/*from   w  w w.java  2 s  .  c  om*/
 *
 * @param callbackContext Callback context of the request from Cordova
 */
public void cancelAll(CallbackContext callbackContext) {
    NotificationManager notificationManager = (NotificationManager) cordova.getActivity()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancelAll();
}

From source file:com.anykey.balala.activity.BaseActivity.java

@Override
protected void onDestroy() {
    super.onDestroy();
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancelAll();
}

From source file:de.baumann.hhsmoodle.popup.Popup_todo_restart.java

private void setTodoList() {

    NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nMgr.cancelAll();

    Schedule_helper.setAlarm(Popup_todo_restart.this);

    Intent serviceIntent = new Intent(Popup_todo_restart.this, class_AlarmService.class);
    startService(serviceIntent);//  w  ww. ja  v a2s. c o  m

    //display data
    final int layoutstyle = R.layout.list_item_notes;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "todo_title", "todo_content", "todo_creation" };
    final Cursor row = db.fetchAllData(Popup_todo_restart.this);
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_todo_restart.this, layoutstyle, row, column,
            xml_id, 0) {
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));

            View v = super.getView(position, convertView, parent);
            ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes);

            switch (todo_attachment) {
            case "true":
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle);
                break;
            default:
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle_red);

                int n = Integer.valueOf(_id);

                android.content.Intent iMain = new android.content.Intent();
                iMain.setAction("shortcutToDo");
                iMain.setClassName(Popup_todo_restart.this, "de.baumann.hhsmoodle.activities.Activity_splash");
                PendingIntent piMain = PendingIntent.getActivity(Popup_todo_restart.this, n, iMain, 0);

                NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(
                        Popup_todo_restart.this).setSmallIcon(R.drawable.school)
                                .setColor(ContextCompat.getColor(Popup_todo_restart.this, R.color.colorPrimary))
                                .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain);

                Notification notification = new NotificationCompat.Builder(Popup_todo_restart.this)
                        .setColor(ContextCompat.getColor(Popup_todo_restart.this, R.color.colorPrimary))
                        .setSmallIcon(R.drawable.school).setContentTitle(todo_title)
                        .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true)
                        .setGroup("HHS_Moodle")
                        .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content))
                        .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build();

                NotificationManager notificationManager = (NotificationManager) Popup_todo_restart.this
                        .getSystemService(NOTIFICATION_SERVICE);
                notificationManager.notify(n, notification);
                notificationManager.notify(0, builderSummary.build());
                break;
            }
            return v;
        }
    };

    lv.setAdapter(adapter);
    //onClick function
    try {
        helper_security.encrypt(Popup_todo_restart.this, "/databases/todo_DB_v01.db",
                "/databases/todo_DB_v01_en.db");
    } catch (Exception e) {
        e.printStackTrace();
    }

    new Handler().postDelayed(new Runnable() {
        public void run() {
            finish();
        }
    }, 1000);
}

From source file:com.z3r0byte.magis.Services.AppointmentService.java

private void setup() {
    if (showNotification) {
        TimerTask notificationTask = new TimerTask() {
            @Override// w w w. ja v a  2s  .  com
            public void run() {
                Gson gson = new Gson();
                appointments = calendarDB.getNotificationAppointments();
                Log.d(TAG, "run: amount " + appointments.length);
                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_date);

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

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

                        NotificationManager mNotificationManager = (NotificationManager) getSystemService(
                                Context.NOTIFICATION_SERVICE);
                        mNotificationManager.notify(9992, mBuilder.build());
                        previousAppointment = gson.toJson(appointment);
                    }
                } else {
                    NotificationManager notifManager = (NotificationManager) getSystemService(
                            Context.NOTIFICATION_SERVICE);
                    notifManager.cancelAll();
                }
            }
        };
        timer.schedule(notificationTask, 20000, 60 * 1000);
    }
}

From source file:com.viettel.dms.util.StatusNotificationHandler.java

/**
*  cancel notifications/*ww  w.  j  a  v  a  2 s .co  m*/
*  @author: TruongHN
*  @param appContext
*  @return: void
*  @throws:
 */
public void cancelNotifications() {
    reset();
    NotificationManager notificationManager = (NotificationManager) GlobalInfo.getInstance().getAppContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancelAll();
}

From source file:com.bonsai.btcreceive.BaseWalletActivity.java

public void doExit() {
    mLogger.info("Application exiting");

    if (mWalletService != null)
        mWalletService.shutdown();// w ww  . j a v a 2  s. c o m

    mLogger.info("Stopping WalletService");
    stopService(new Intent(this, WalletService.class));

    // Cancel any remaining notifications.
    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nm.cancelAll();

    mLogger.info("Finished");
    finish();
    mLogger.info("Exiting");

    System.exit(0);
}

From source file:fr.s13d.photobackup.PBService.java

@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
    super.onStartCommand(intent, flags, startId);

    if (intent != null) { // explicitly launch by the user

        // stopped by the notification
        if (intent.getAction() != null && intent.getAction().equals(PBApplication.PB_STOP_SERVICE)) {
            if (mediaSender != null) {
                LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
                Toast.makeText(this, R.string.service_stopped, Toast.LENGTH_LONG).show();

                // remove the notification
                NotificationManager notificationManager = (NotificationManager) getSystemService(
                        Context.NOTIFICATION_SERVICE);
                notificationManager.cancelAll();
            }/* www.  jav  a  2  s .  c  o  m*/
            stopSelf();
            return START_NOT_STICKY;
        }

        Log.i(LOG_TAG, "PhotoBackup service has started");
    }

    return START_STICKY;
}

From source file:org.secuso.privacyfriendlynetmonitor.ConnectionAnalysis.PassiveService.java

private void showNoNotification() {
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancelAll();
}

From source file:ch.bfh.instacircle.service.NetworkService.java

@Override
public void onDestroy() {

    // Stop everything if the leave message is coming from myself
    try {//from w  ww.  j a  v  a 2  s .c o  m
        for (int i = 0; i < tcpUnicastReceiverThreads.length; i++) {
            tcpUnicastReceiverThreads[i].interrupt();
            udpBroadcastReceiverThreads[i].interrupt();
            tcpUnicastReceiverThreads[i].serverSocket.close();
            udpBroadcastReceiverThreads[i].socket.close();
        }
    } catch (Exception e) {

    }

    dbHelper.closeConversation();

    WifiManager wifiman = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    new AdhocWifiManager(wifiman).restoreWifiConfiguration(getBaseContext());
    WifiAPManager wifiAP = new WifiAPManager();
    if (wifiAP.isWifiAPEnabled(wifiman)) {
        wifiAP.disableHotspot(wifiman, getBaseContext());
    }
    stopSelf();
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    notificationManager.cancelAll();
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    startActivity(intent);
    // Unregister the receiver which listens for messages to be sent
    LocalBroadcastManager.getInstance(this).unregisterReceiver(messageSendReceiver);

    // close the DB connection
    dbHelper.close();
    super.onDestroy();
}