Android Question Screen bright when powered, sleep(dark) when no power

gezueb

Active Member
Licensed User
Longtime User
I would like to achieve the above. Using the standard phone settings, I can manage to keep the phone awake while the power is on and sleep when its off, however, the screen dims after a while. Using Power Wake State I can keep it bright, but then it runs on the battery when the external power is off, something I dont want (its an in-car application)
I guess one could use the PhoneEvents to detect power change, in this case I would be glad if soneone can help with a sample code for the service module. Alternatively, is there a method to prevent the phone from going to sleep with a timer loop and doevents?
Thanks for help, Georg
 

gezueb

Active Member
Licensed User
Longtime User
Thank you as always, Erel! I had to find out how to start a service, as it is now "Service_Start(StartingIntent As Intent)" and not only "Service_Start" without params as in an example I found, but it works now okay. Ignoring the CallSubDelayed method, I set a global variable according to the power state and check it in a timer loop in the main activity to Release Wake State when charging power is lost. But your method is far more elegant!
 
Upvote 0
Top