I making a app, where you can set alarms. For example, I have class on Mondays at 7o' clock, so I need to start the alarm every Monday, but also I have another class on Tuesday and have to do it the same.
I already can do that and works, with an alarm for each curso, but when I reboot the cellphone then they don't work .
Here is my code the put extra is so important in my app:
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.set(Calendar.HOUR_OF_DAY, horai);
cal.set(Calendar.MINUTE, minutoi);
cal.set(Calendar.DAY_OF_WEEK, dias.getSelectedItemPosition() + 1);
cal.add(Calendar.SECOND, 2);
Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
intent.putExtra("name", curso);
//intent.putExtra("curos bn",1);
PendingIntent pendingIntent =
PendingIntent.getBroadcast(getBaseContext(),
cont, intent, PendingIntent.FLAG_UPDATE_CURRENT );//cont star with 1 a then ++
RECEIVER
public class AlarmReceiver extends BroadcastReceiver {
private static final String TAG = "BANANEALARM";
Intent intent;
PendingIntent pendingIntent;
NotificationManager notificationManager;
private static final int PERIOD=5000;
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "BroadcastReceiver has received alarm intent.");
Intent service1 = new Intent(context, AlarmService.class);
String id = intent.getStringExtra("name"); // this is so important
service1.putExtra("name",id);
context.startService(service1);
}
Manifets
<receiver android:name=".AlarmReceiver" android:enabled="true" >
</receiver>
<service android:name=".AlarmService" />
So in other part of my application I set alarms with data that I get from a json. All works like I want the only problem is when I reboot the phone?