I have in my code an alarm that is supposed to ring when the 22:48 hours arrive but nothing happens now I wonder if the hours that the calendar uses are the system hours? if so what am i doing wrong so my alarm does not show up?
I call the function to insert a new alarm when clicking on a list:
boolean res = MyUtility.addFavorite(HorariosActivity.this, horarioitem,
HorariosActivity.this.getApplicationContext());
The function returns a boolean value if it is true
added to favorites.
In my Utility class I have the code that supposedly would ring the alarm:
public static boolean addFavorite(Activity activity, String favItem , Context context) {
String favList = getStringFromPreferences(activity, null, EVENTOS);
AlarmManager alarmMgr;
PendingIntent alarmIntent;
alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, MainActivity.class);
alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 22);
calendar.set(Calendar.MINUTE, 55);
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 1000 * 60 * 10 , alarmIntent);
}
I while testing the application I leave it always open because I know that restart case by what I know the alerts are lost, it still does not work my alert.