Is there a away to detect the event when iOS device goes to sleep mode (when the screen gets blackened)?

You basically already have the solution, which I’m guessing you found from one of my recent answers 🙂 Use the com.apple.springboard.hasBlankedScreen event. There are multiple events that occur when the screen blanks, but this one should suffice: CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center NULL, // observer hasBlankedScreen, // callback CFSTR(“com.apple.springboard.hasBlankedScreen”), // event name NULL, // object CFNotificationSuspensionBehaviorDeliverImmediately); where the … Read more

Android Sleep/Standby Mode

I’m sure the workaround isn’t too difficult Using AlarmManager is a bit tricky. My question is what exactly does “sleep mode” do on android systems? Primarily, it shuts down the CPU. Along the way, non-essential radios (WiFi, GPS) will have been shut down as well. What does it stop, what doesn’t it stop, etc. About … Read more

show remaining minutes instead of hours

Barebones solution: long remainingMillis = countdownEnds.getTime() – System.currentTimeMillis(); long remainingMinutes = TimeUnit.MILLISECONDS.toMinutes(remainingMillis); String countdownEndsString = String.format(“%d minutes”, remainingMinutes); For a nicer solution use java.time, the modern Java date and time API, for the calculation of the minutes: long remainingMinutes = ChronoUnit.MINUTES.between( Instant.now(), DateTimeUtils.toInstant(countdownEnds)); In this case also see if you can get rid of the … Read more