I have an app that uses text to speech to inform the user every 10 mins that 10 mins have passed. It currently works fine but if you sleep the phone (press the power button) it no longer plays the sound.
How can i play these sounds even when the phone is asleep?
In general, your code is not running if divice goes to sleep. In order to make your code running you need to acquire WakeLock from PowerManager. But in your case you don’t need to have the WakeLock acquired all the time. You need to wake you application every 10 minutes. Otherwise your app will just eat battery doing nothing.
In order to wake your application periodically you need to use a special Android’s AlarmManager.
Here is an example:
You also may send broadcast which you will process in your Service (if you don’t want to use Activity).
EDIT: Playback will not start unless you explicitly create a SCREEN_DIM_WAKE_LOCK. Note that PARTIAL_WAKE_LOCK will not work with playback (don’t now why, probably it’s a bug).
EDIT: Added project that shows an example of running a playback every 60 seconds (even when screen is off and usb cable is disconnected). It can be found here: http://code.google.com/p/playevery60/