I’ve created alarm for each event in calendar while created. It works fine. Now if i set an event for 6pm and if i switch off and switch on the device, the alarm is ringing suddenly when the device is switched on. the alarm is not ringing for the event set time. My code for OnBootReceiver as follows:
@Override
public void onReceive(Context context, Intent intent)
{
AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i=new Intent(context, AlarmReceiver.class);
PendingIntent pi=PendingIntent.getBroadcast(context, ap.id1,i, 0);
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime(),PERIOD,pi);
}
First of all save that timings in one databse
call a broad cast reveiver class like below
use below code in manifest file
in above code
SampleOnBootReceiveris acalss which extends fromBroadcastReceiver.in that class u take alaram time from saved databse and set the alaram