Guest User

Untitled

a guest
Jan 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. Intent intent = new Intent(this, ViewLocalReminders.class);
  2. startActivity(intent);
  3.  
  4. //Get the primary key of the reminder that has just been saved.
  5. Cursor cursor = remindersDAO.reminderNotification(this);
  6. cursor.moveToLast();
  7. int reminderIdColumnIndex = cursor.getColumnIndex("_id");
  8. reminderPrimaryKey = cursor.getInt(reminderIdColumnIndex);
  9.  
  10. //Get the name of the reminder that has just been saved.
  11. cursor.moveToLast();
  12. int reminderNameColumnIndex = cursor.getColumnIndex("name");
  13. reminderName = cursor.getString(reminderNameColumnIndex);
  14.  
  15. cursor.close();
  16.  
  17. Toast toast = Toast.makeText(context, context.getString(R.string.reminder_saved), Toast.LENGTH_LONG);
  18. toast.show();
  19.  
  20. c.set(mYear, mMonth, mDay); //Set the notification date.
  21. c.set(Calendar.HOUR_OF_DAY, pHour); //Set the notification hour.
  22. c.set(Calendar.MINUTE, pMinute); //Set the notification minute.
  23. c.set(Calendar.SECOND, 0); //Set the notification second (always 0).
  24.  
  25. //Use AlarmManager to trigger the notification/alarm.
  26. AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
  27.  
  28. //PendingIntent to launch activity when the alarm triggers.
  29. Intent i = new Intent("com.utilityapps.Blah.DisplayReminderNotification");
  30.  
  31. //Assign the reminder's primary key as the notification ID.
  32. i.putExtra("Reminder_Name", editRemindMeTo.getText().toString());
  33. i.putExtra("Reminder_Primary_Key", reminderPrimaryKey);
  34.  
  35. PendingIntent displayIntent = PendingIntent.getActivity(getBaseContext(), reminderPrimaryKey, i, 0);
  36.  
  37. //Set the alarm to trigger.
  38. alarmManager.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), displayIntent);
  39.  
  40. Intent i = new Intent("com.utilityapps.Blah.DisplayReminderNotification");
  41. PendingIntent displayIntent = PendingIntent.getService(context, (int) reminderID, i, PendingIntent.FLAG_CANCEL_CURRENT);
  42.  
  43. AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
  44.  
  45. alarmManager.cancel(displayIntent);
  46. displayIntent.cancel();
  47.  
  48. AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
  49.  
  50. Intent i = new Intent("com.utilityapps.Blah.DisplayReminderNotification");
  51.  
  52. PendingIntent displayIntent = PendingIntent.getActivity(getBaseContext(), reminderPrimaryKey, i, 0);
  53.  
  54. alarmManager.cancel(displayIntent);
Add Comment
Please, Sign In to add comment