I am trying to set an alarm when activity is destroyed. But it is not working. If I set an alarm when activity is stopped, it is working. But for the destroying method, it is not working. I don't know if I am missing something or what ? If it is possible,how can I set an alarm when activity is destroyed?
Following is my code:
@Override
protected void onDestroy() {
databaseHandler.updatePreference(Keys.Pref.APP_CRASH_STATUS, "TRUE");
setAlarmToOpenApp();
super.onDestroy();
}
private void setAlarmToOpenApp(){
Intent alarmIntent = new Intent(ActivityDisplay.this, AppCrashReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(ActivityDisplay.this, 0, alarmIntent, 0);
AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
int interval = 10000;
manager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 10000, pendingIntent);
Display.log(TAG, "Alarm is set to Broadcast app crash");
}