1.

My Script Stops Working When The Screen Turns Off! Wtf?

Answer»

Your phone turns the screen off, among other things, when it GOES to sleep. If an application doesn't request that it keep RUNNING when the phone is asleep, it will stop running until the phone wakes up again (i.e. you turn the screen back on). Requesting that the device remain on while your application is running is called a wake lock.

SL4A provides APIs for acquiring and releasing wake locks. It is important to note that wake locks SIGNIFICANTLY impact battery life. You should always RELEASE a wake lock as soon as possible.

Instead of using a wake lock, you can also enable the "Stay awake" system setting. From your home screen tap Menu, Applications, Development, and CHECK Stay awake. With that enabled, your phone will never sleep while charging. This does affect the amount of time it takes to charge your phone, however.

Your phone turns the screen off, among other things, when it goes to sleep. If an application doesn't request that it keep running when the phone is asleep, it will stop running until the phone wakes up again (i.e. you turn the screen back on). Requesting that the device remain on while your application is running is called a wake lock.

SL4A provides APIs for acquiring and releasing wake locks. It is important to note that wake locks significantly impact battery life. You should always release a wake lock as soon as possible.

Instead of using a wake lock, you can also enable the "Stay awake" system setting. From your home screen tap Menu, Applications, Development, and check Stay awake. With that enabled, your phone will never sleep while charging. This does affect the amount of time it takes to charge your phone, however.



Discussion

No Comment Found