when you turn on the alarm, you must call the built-in alarm manager and use alarmmanager.set to set the alarm time in the manager. When the alarm time (in milliseconds) is sent to the alarm manager, it will send a message and you can receive the message through the receiver class
//creating and assigning value to alarm manager class Intent AlarmIntent = new Intent(MainActivity.this, AlarmReciever.class); AlarmManager AlmMgr = (AlarmManager)getSystemService(ALARM_SERVICE); PendingIntent Sender = PendingIntent.getBroadcast(MainActivity.this, 0, AlarmIntent, 0); AlmMgr.set(AlarmManager.RTC_WAKEUP, Alarm.getTimeInMillis(), Sender);
To receive an alarm, you must create a new class that extends the receiver, where in onrecieve you can set the intention for the activity that you want to call during the alarm, you can also provide a notification.
public class AlarmReciever extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) {
If you still have problems, ask again. :)
Scorpian
source share