• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Execute method when alarm is set

ARTUL

Lurker
Hello all,
This is a part of the code that I want to execute turnOn method when the alarm is set. For some reason it doesnt execute the method and I don't know why. Can someone help me?

Thank you.



private void startAlarm(Calendar c)
{
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
if (c.before(Calendar.getInstance()));
{
c.add(Calendar.DATE, 1);
}

Intent intent = new Intent(ledControl.this, Control.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,1,intent, 0);
alarmManager.setExact(AlarmManager.RTC_WAKEUP,c.getTimeInMillis(), pendingIntent);

}
public class Control extends BroadcastReceiver
{
@override
public void onReceive(Context context, Intent intent) {
turnOnLed(); // method to turn on

}
}
}
 
Back
Top Bottom