0

My app will allow user to set desired time on which activity will trigger. I used AlarmManager to open activity. Below is the code for same.`

   /* Intent intent = new Intent(this, AlarmNotificationActivity.class);
    PendingIntent pendingIntent=PendingIntent.getActivity(getBaseContext(), RQS_1, intent,
            0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(),interaval, pendingIntent);*/

    Intent intent = new Intent(this, AlarmReceiver.class);
    PendingIntent pendingIntent=PendingIntent.getBroadcast(getBaseContext(), RQS_1, intent,
            0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(),interaval, pendingIntent);

If I use the PendingIntent with getActivity even the app killed AlarmNotification is came up.

If I use the PendingIntent with getBroadcast if the app killed AlarmNotification is not coming up.

Question is After clearing the app process from task list Is it possible to trigger Notification Activity of my app through broadcast.

  • If Yes - Please share any link or sample code (TIA)

  • If No - How Clock App in Mobile triggers Alarm on specific time. Do I need to define service to achieve this.

Manju
  • 720
  • 9
  • 23
  • please correct me If I am wrong, Do you want to start the application when an app is killed? And to start the app you are using alarm manager? – Jitesh Mohite Apr 27 '18 at 06:55
  • Yes. But there is confusion here. In App code I already set alarm isn't it. Will that data also be cleared. Even app starts again what is the state of Alarm then. bdw thanks for reply. What will be the use of alarm set before? – Manju Apr 27 '18 at 07:02
  • What device have you tested this on? – David Wasser Apr 30 '18 at 14:53
  • Your question is not clear. You mention using `BroadcastReceiver` and `Activity` using `AlarmManager`, then you mention `Notification`. Your code example is not complete and it is difficult to follow what you want to do. – David Wasser Apr 30 '18 at 14:54

0 Answers0