To be more exact, I want to do following: AlarmReceiver-Broadcaster should be executed every day two times: Is TimerTask still the better solution?
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 18);
calendar.set(Calendar.MINUTE, 54);
Intent intentAlarm = new Intent(context, AlarmReceiver.class);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
PendingIntent.getBroadcast(context, 1, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT));
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 17);
calendar.set(Calendar.MINUTE, 58);
Intent intentAlarm2 = new Intent(context, AlarmReceiver.class);
AlarmManager alarmManager2 = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager2.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
PendingIntent.getBroadcast(context, 1, intentAlarm2, PendingIntent.FLAG_UPDATE_CURRENT));
I think what you are looking for is TimerTask in Android. Here is an example how to use it example.