Guest User

Untitled

a guest
Jan 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. onCreate(Bundle savedInstanceState) {
  2.  
  3. ...
  4.  
  5. NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  6. Notification notif = new Notification(R.drawable.flag_red_large, reminderName, System.currentTimeMillis());
  7.  
  8. notif.deleteIntent = PendingIntent.getService(this, notifID, new Intent(this, CleanUpIntent.class), 0);
  9.  
  10. //Destroy the activity/notification.
  11. finish();
  12.  
  13. }
  14.  
  15. class CleanUpIntent extends IntentService {
  16. public CleanUpIntent() {
  17. super("CleanUpIntent");
  18. }
  19.  
  20. @Override
  21. protected void onHandleIntent(Intent arg0) {
  22. System.out.println(">>>>>>>>>>>>>>>>>>>" + "Repeating Alarm Cancelled...");
  23.  
  24. Intent i = new Intent("com.utilityapps.YouForgotWhat.DisplayReminderNotification");
  25. int reminderID = i.getExtras().getInt("reminderID");
  26.  
  27. PendingIntent displayIntent = PendingIntent.getBroadcast(this, reminderID, i, PendingIntent.FLAG_CANCEL_CURRENT);
  28.  
  29. AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
  30.  
  31. alarmManager.cancel(displayIntent);
  32. displayIntent.cancel();
  33. }
  34.  
  35. }
  36.  
  37. }
Add Comment
Please, Sign In to add comment