asif49 9 Posting Whiz in Training

Hi!

I'm interested in being able to detect when someone goes from an awake state to a sleep state.

I know this is possible with both the iPhone and Android devices as there are apps on both of these that claim to do this:
On IOS there are:
1) Sleep meister
2) Sleep cycle

And "Sleep for Android" on Android.

All of these make claims in the arena of 'using motion detection/microphone to ascertain when user has fallen asleep' and require the phone on a level footing to the bed. Is there an API that someone has heard of which would allow me to do this on either type of devices? Any knowledge or pointers would be helpful!