List of usage examples for android.app NotificationManager cancel
public void cancel(int id)
From source file:org.wso2.emm.agent.services.NotificationService.java
@Override public void onReceive(Context context, Intent intent) { int operationId = intent.getIntExtra(Constants.OPERATION_ID, DEFAULT_VALUE); if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "NotificationId: " + operationId); }//w w w. ja v a 2s. co m updateNotification(operationId); // updating notification state to DISMISSED NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(operationId); }
From source file:com.jameswolfeoliver.pigeon.Services.PigeonService.java
private void clearNotification() { NotificationManager notificationManager = (NotificationManager) getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID); }
From source file:org.chatsecure.pushdemo.MainActivity.java
private void dismissNotification(int id) { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(id); }
From source file:org.adblockplus.android.configurators.ManualProxyConfigurator.java
private void removeErrorNotification() { final NotificationManager notificationManager = (NotificationManager) this.context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTRAFFIC_NOTIFICATION_ID); }
From source file:org.envirocar.app.application.service.DeviceInRangeService.java
@Override public void onDestroy() { logger.info("onDestroy " + getClass().getName() + "; Hash: " + System.identityHashCode(this)); unregisterReceiver(receiver);//from w w w.jav a 2s .co m NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(BackgroundServiceImpl.BG_NOTIFICATION_ID); discoveryEnabled = false; discoveryHandler.removeCallbacks(discoveryRunnable); }
From source file:com.google.android.apps.iosched.calendar.SessionAlarmService.java
private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(NOTIFICATION_ID); final long currentTime = System.currentTimeMillis(); // If the session is already started, do not schedule system notification. if (currentTime > sessionStart) { return;//from w w w. ja v a 2 s.c om } // By default, sets alarm to go off at 10 minutes before session start time. If alarm // offset is provided, alarm is set to go off by that much time from now. long alarmTime; if (alarmOffset == UNDEFINED_ALARM_OFFSET) { alarmTime = sessionStart - TEN_MINUTES_MILLIS; } else { alarmTime = currentTime + alarmOffset; } final Intent alarmIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class); // Setting data to ensure intent's uniqueness for different session start times. alarmIntent.setData(new Uri.Builder().authority(ScheduleContract.CONTENT_AUTHORITY) .path(String.valueOf(sessionStart)).build()); alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart); alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd); alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset); final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); // Schedule an alarm to be fired to notify user of added sessions are about to begin. am.set(AlarmManager.RTC_WAKEUP, alarmTime, PendingIntent.getService(this, 0, alarmIntent, PendingIntent.FLAG_CANCEL_CURRENT)); }
From source file:com.conferenceengineer.android.iosched.service.SessionAlarmService.java
private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(NOTIFICATION_ID); final long currentTime = UIUtils.getCurrentTime(this); // If the session is already started, do not schedule system notification. if (currentTime > sessionStart) return;//w w w . j a v a 2 s . co m // By default, sets alarm to go off at 10 minutes before session start time. If alarm // offset is provided, alarm is set to go off by that much time from now. long alarmTime; if (alarmOffset == UNDEFINED_ALARM_OFFSET) { alarmTime = sessionStart - MILLI_TEN_MINUTES; } else { alarmTime = currentTime + alarmOffset; } final Intent notifIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class); // Setting data to ensure intent's uniqueness for different session start times. notifIntent.setData(new Uri.Builder().authority("com.conferenceengineer.android.iosched") .path(String.valueOf(sessionStart)).build()); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset); PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT); final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); // Schedule an alarm to be fired to notify user of added sessions are about to begin. am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi); }
From source file:com.antonioleiva.materialeverywhere.HomeActivity1.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarIcon(R.drawable.ic_ab_drawer); GridView gridView = (GridView) findViewById(R.id.gridView); gridView.setAdapter(new GridViewAdapter()); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override// w w w.j a v a 2s . com public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String url = (String) view.getTag(); DetailActivity.launch(HomeActivity1.this, view.findViewById(R.id.image), url); } }); drawer = (DrawerLayout) findViewById(R.id.drawer); drawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); NotificationManager notifier = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notifier.cancel(ACTION_NOTIFICATION_ID); //? ?? Intent intent1 = new Intent(this, HomeActivity1.class); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, ACTION_NOTIFICATION_ID, intent1, 0); NotificationCompat.WearableExtender secondWearableExtender = new NotificationCompat.WearableExtender() .setContentIcon(R.drawable.ic_launcher).setContentIconGravity(Gravity.CENTER); //step4 Notification secondPage = new NotificationCompat.Builder(this).setContentTitle("Step 4") .setContentText(" ? ? ? ?.") .extend(secondWearableExtender).build(); //5 NotificationCompat.Action step5 = new NotificationCompat.Action(R.drawable.ic_launcher, "step5", viewPendingIntent); //step5 Notification thirdPage = new NotificationCompat.Builder(this).setContentTitle("Step 5") .setContentText(" .") .extend(new NotificationCompat.WearableExtender().setContentIcon(R.drawable.ic_launcher) .setContentIconGravity(Gravity.CENTER).setContentAction(0)) .build(); //step6 Notification fourthPage = new NotificationCompat.Builder(this).setContentTitle("Step 6") .setContentText(" ? .") .extend(new NotificationCompat.WearableExtender().setContentIcon(R.drawable.ic_launcher) .setContentIconGravity(Gravity.CENTER)) .build(); // ?? ? ?. //?, ? NotificationCompat.WearableExtender wearableOptions = new NotificationCompat.WearableExtender() .setContentIcon(R.drawable.ic_launcher).setContentIconGravity(Gravity.CENTER).addAction(step5) .addPage(secondPage).addPage(thirdPage).addPage(fourthPage); // ? ? ? Notification notification = new NotificationCompat.Builder(this).setContentTitle("?") .setContentText("2").setUsesChronometer(true).setSmallIcon(R.drawable.ic_launcher) .extend(wearableOptions).setAutoCancel(true).build(); //? // ? ? . NotificationManagerCompat.from(this).notify(RECIPE_NOTIFICATION_ID, notification); }
From source file:com.google.android.apps.muzei.datalayer.ActivateMuzeiIntentService.java
@Override protected void onHandleIntent(Intent intent) { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String action = intent.getAction(); if (TextUtils.equals(action, ACTION_MARK_NOTIFICATION_READ)) { preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); return;//from w ww. j a v a2 s . c o m } else if (TextUtils.equals(action, ACTION_REMOTE_INSTALL_MUZEI)) { Intent remoteIntent = new Intent(Intent.ACTION_VIEW).addCategory(Intent.CATEGORY_BROWSABLE) .setData(Uri.parse("market://details?id=" + getPackageName())); RemoteIntent.startRemoteActivity(this, remoteIntent, new ResultReceiver(new Handler()) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { if (resultCode == RemoteIntent.RESULT_OK) { FirebaseAnalytics.getInstance(ActivateMuzeiIntentService.this) .logEvent("activate_notif_install_sent", null); preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); } else { Toast.makeText(ActivateMuzeiIntentService.this, R.string.activate_install_failed, Toast.LENGTH_SHORT).show(); } } }); return; } // else -> Open on Phone action GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build(); ConnectionResult connectionResult = googleApiClient.blockingConnect(30, TimeUnit.SECONDS); if (!connectionResult.isSuccess()) { Log.e(TAG, "Failed to connect to GoogleApiClient."); Toast.makeText(this, R.string.activate_failed, Toast.LENGTH_SHORT).show(); return; } Set<Node> nodes = Wearable.CapabilityApi .getCapability(googleApiClient, "activate_muzei", CapabilityApi.FILTER_REACHABLE).await() .getCapability().getNodes(); if (nodes.isEmpty()) { Toast.makeText(this, R.string.activate_failed, Toast.LENGTH_SHORT).show(); } else { FirebaseAnalytics.getInstance(this).logEvent("activate_notif_message_sent", null); // Show the open on phone animation Intent openOnPhoneIntent = new Intent(this, ConfirmationActivity.class); openOnPhoneIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); openOnPhoneIntent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.OPEN_ON_PHONE_ANIMATION); startActivity(openOnPhoneIntent); // Clear the notification NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(INSTALL_NOTIFICATION_ID); preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); // Send the message to the phone to open Muzei for (Node node : nodes) { Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), "notification/open", null).await(); } } googleApiClient.disconnect(); }
From source file:org.gluu.super_gluu.app.activities.MainActivity.java
private void userChossed(String answer, Intent intent) { Boolean isAppLocked = Settings.isAppLocked(getApplicationContext()); String requestJson = intent.getStringExtra(GluuMainActivity.QR_CODE_PUSH_NOTIFICATION_MESSAGE); saveUserDecision(answer, requestJson); if (isAppLocked) { loadLockedFragment(true);//from www. j a va 2 s . co m } else { checkPinCodeEnabled(); } NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nMgr.cancel(GluuMainActivity.MESSAGE_NOTIFICATION_ID); }