Keep phone/tablet screen from dimming

I had an extra tablet, no longer in use, and decided to put it to work. Very simple, it displays the time in bold red numbers and looks just like your garden variety clock. I’ve used this for a couple of years without major issue. It is always plugged in just like a normal clock.

I decided to update it to also function as an alarm clock but was bothered by the screen dimming. Even my newer Android 11 has a max of 30 min before diming. But I noticed that if a video was being displayed, the phone never dimmed (makes sense), and was planning to use video as a wake up call anyway. So I added a second video object in a loop to use for this purpose. Pesto, no dimming.

Note that I did have a problem getting this video to autoplay on app start. I worked around this by not displaying the time until the user clicked on a “Start” button which issued Video1.play() and then showed the time. I tested this by keeping the Video1 hidden, but this may not work on newer devices since a smarter OS might be able to notice that the video is not visible and dim the screen. So another way is to keep the video displayed but just way off the left side of the screen so it doesn’t interfere. For some reason putting far to the right of the active form seems to extend the width of the form, which I don’t find acceptable. Note also that the video can be anything you want, but the shorter the better and it should not play any sound.

If you’re writing a kiosk app this could be quite helpful. Maybe there are other ways to “fool” the OS into thinking you’re still alive and working the app, but I couldn’t find any.

A minor issue is that phones/tablets have a tendency to loose time and a reboot will get it back in line. I noticed that some reviewers of tablet size “reminder” devices have the same issue. When/If I get the time I may use something like this to keep the time on time without needing to reboot:

$.ajax({
    dataType: 'jsonp',
    url: 'http://timeapi.org/utc/now.json',
    success: function (result) {
        alert(result.dateString);
    }
}); 

John

Fun tip - thank you!