Tell when Android Tablet is charging?

I’ve been asked to develop a very simple product display app for distribution in multiple stores.

The tablet will be plugged in and charging on a display unit. The app is ‘always on’ with the app running on full brightness - no screen dimming. I handle this in lua with a call to 

system.setIdleTimer( false ) 

However, after a meeting today with the client, they said that most storekeepers will switch the tablet ‘off’ at night, which means the tablet’s battery will fully discharge overnight, or across a Sunday.

So - is there a way to tell when the tablet is charging / plugged in?

I would like to cause the app and tablet to ‘sleep’ when not charging and then ‘wake’ when the power is switched on again. 

You will need to use Corona Enterprise or CoronaCards for this.

Rob

You will need to use Corona Enterprise or CoronaCards for this.

Rob