0

I'm learning about the android. Now, I want to display a button that can turn off the screen. That is when the user click the button the screen off as the user click the power button. How can I do this? Thank you.

jjyao
  • 315
  • 5
  • 16

1 Answers1

1

Hi try looking at a previous thread.

Calling hidden API in android to turn screen off

But if you are just learning Android, there might be more simple things to try first :) see the developer guide on http://developer.android.com/guide/index.html

Community
  • 1
  • 1
Mads Lee Jensen
  • 4,570
  • 5
  • 36
  • 53
  • I saw this thread. But I can't understand completely. Is this means that I can't do this if I don't want to call the hidden api. – jjyao Oct 18 '10 at 13:12
  • As they describe in the thread, you can only manipulate the screen brightness. – Mads Lee Jensen Oct 18 '10 at 13:50
  • @madsleejensen But if you change the brightness to 0, that's the same effect as turning off the screen, as it actually turns off the screen. So it can be achieved with official SDK api, no need to use the hidden one (which btw I couldn't get to run on Android 2.3.x, even setScreenState is called with false, and I see it in the log, the screen does NOT turn off, code: http://pastebin.com/WQKR857z). – Mathias Conradt Jun 02 '12 at 16:13