I have an app where I want to set alarm on specific date and time . Let say 5:00pm of 16 march. I want this alarm to be schedule as non repeating alarm.
Now the alarm is setting and working. but it is only working when App is working or in background. but when app is force closed it is not working.
here is what I am doing:
public void startAlert() {
EditText text = (EditText) findViewById(R.id.time);
int i = Integer.parseInt(text.getText().toString());
Intent intent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this.getApplicationContext(), 234324243, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
+ (i * 1000), pendingIntent);
Toast.makeText(this, "Alarm set in " + i + " seconds",Toast.LENGTH_LONG).show();
}
Well this code is just for demonstration. The problem is when I have cleared my app from the app task manager the alaram does not alaram.
I know there are some problems, as android os unregister scheduled alarms , also there could be problem on reboot.
For the time Now I really do not care about about the reboot, but alarm should work when app is forced to close. If it is not applicable in android then how other apps are doing this ???
Please share your views about it ? and tell me anyother solution to how to notify my user at specific time of a day even my app is not there even in background ?? please help