How to prevent tablet working when laid flat? My son has the bad habit of putting his tablet flat on the floor (even though it has a hard-shell case with built-in stand) and leaning over it, which is an ergonomic nightmare.

No matter how much I explain and demonstrate the correct operating position (he's four), when left to his own devices (device) during "Tablet Time", he inevitably moves it back onto the floor, often unconsciously. So...

How can I use the tablet's sensors to detect that it has been laid flat and go to sleep / switch off / post a notice / message me / something?

;o) Cor
With Tasker is very simple (note that it is a paid app):


Create a profile (in the 'profile' tab tap on the plus sign)
Choose 'State' -> 'Sensor' -> 'Orientation' and from the drop down menu 'Face Up'
Go back to profiles tab and you will be prompted to add a task to your profile: tap on the plus sign in the little pop up
Now it depends from what you want the tablet to do when lying flat, you can choose all kind of possible actions: send SMS (if the tablet has a sim card), lock the screen (so your son will need to come for you to unlock it), and so on. Pick the one you want between the multiple choices and add it to your task
Enable Tasker (long tapping on the Tasker icon in the top left corner)


Note that, as mentioned in the comments, Tasker won't be able to understand if the tablet is lying on the floor or on a table. You may want to add a condition that activates the profile only when it's 'Tablet time' (which is, during the time of the day when you let your son play with it).