I'm trying to check if my alarm is active or not. The alarmIsSet method will return false before the alarm is set, true when the alarm is set. So far so good, however, after the alarm i canceled alarmIsSet will continue to return true until I reboot the device. How do I fix this?
public class Alarm extends Activity {
private Intent intent = new Intent("PROPOSE_A_TOAST");
private void alarm (boolean activate) {
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, 0);
if(activate == true) {
int type = AlarmManager.ELAPSED_REALTIME_WAKEUP;
long interval = 3000;
long triggerTime = SystemClock.elapsedRealtime();
am.setRepeating(type, triggerTime, interval, pi);
} else {
am.cancel(pi);
}
}
private boolean alarmIsSet() {
return PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_NO_CREATE) != null;
}
}
To check for the alarm clock icon/indicator, swipe down from the top right of the screen to bring down your iPhone's control panel. If you have set an alarm, you'll see the clock icon just to the left of the battery indicator.
You may have Sleep as Android enabled under Border lights (Edge Lightning on some versions). This causes the alarm popup to not display over the lockscreen, as the notification is being shown as a light around the edge of the screen. Disable Border lights for Sleep as Android in your device's settings.
Answer: A: The space in the top status bar is limited with the notch on the newer iPhones. To ensure that your alarm is on, you can swipe down from the upper right corner of the screen to bring up Control Center. If the alarm is on, the icon will appear near the battery and battery percent icon.
You just have to add
pi.cancel();
after
am.cancel(pi);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With