Android: disconnect screen from service

I am trying to figure out how to turn off the screen from a service. I already read this one , but I don’t understand how to do this from the service. I really don't want to deal with locks after, as soon as the screen goes blank, I still do not need to return it using java code. I just needed once to turn off the screen, and I always looked for it.

+4
android android-activity screen service
May 6 '11 at 9:27
source share
1 answer

I see two options:

(1) Create an Activity dummy and use it to get a Window object using the getWindow(); method getWindow(); . You should then use Intent to display the screen from your Service .

(2) Use IHardwareService.Stub . Not part of the SDK, but there is a workaround in this blog post: http://www.tutorialforandroid.com/2009/01/changing-screen-brightness.html

By the way: I would highly recommend the first option. You never know when a class that is not part of the SDK can change.

+3
May 6 '11 at 10:00
source share



All Articles