I am working on a signaling application. I followed the Android AlarmController tutorial verbatim with some minor changes. For some reason, my onReceive () receiver is not being called when the alarm goes off. Here is the code:
private TimePickerDialog.OnTimeSetListener mTimeSetListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
time.set( Calendar.HOUR_OF_DAY, hourOfDay );
time.set( Calendar.MINUTE, minute );
String timeSetTo = "Alarm Set: " + time.get( Calendar.HOUR_OF_DAY ) + ":" + time.get( Calendar.MINUTE ) + " " + time.get( Calendar.AM_PM );
if( toast != null )
toast.cancel();
toast = Toast.makeText( AlarmUI.this, "L" + timeSetTo, Toast.LENGTH_LONG );
toast.show();
Intent intent = new Intent( AlarmUI.this, AlarmAction.class );
PendingIntent sender = PendingIntent.getBroadcast( AlarmUI.this, 0, intent, 0 );
AlarmManager alarmManager = ( AlarmManager ) getSystemService( ALARM_SERVICE );
alarmManager.set( AlarmManager.RTC_WAKEUP, time.getTimeInMillis(), sender );
}
};
Any ideas? Thank you in advance.
source
share