1
I have in my code an alarm that is supposed to ring when the hours arrive at 22:48 but nothing happens now I wonder if the hours that Calendar uses are the system hours ? if yes what I am doing wrong so my alarm does not appear ?
I call the function to insert a new Alarm by clicking on a list :
boolean res = MyUtility.addFavorite(HorariosActivity.this, horarioitem,
HorariosActivity.this.getApplicationContext());
the function returns a boleano value if it is true
bookmarks.
In my Utility class I have the code that was supposed to play 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);
}
While testing the application I always leave it open because I know that the case of Restart so I know the Alerts are lost , still does not work my Alert.
I already modified the code and still not receiving the expected alarm any suggestion?
– Tiago Coelho
What do you mean, "I still don’t get the expected alarm"? What do you expect to happen with the "trigger" of the alarm?
– ramaral
It was a misunderstanding on my part. Thanks for the help is working the alarm now I have another problem with the firing of a notification but I’ll open another question for that.
– Tiago Coelho