Friday, October 23, 2009

[android-developers] How to turn off the screen display?

Hi All,

I have a requirement to turn the screen display on and off from a Android Service. I should have a function SwitchScreenDisplay (ON/OFF), to ON or OFF the display.

I searched through the SDK and found a few APIs and settings. One method I found is 
boolean err = android.provider.Settings.Secure.putInt(myThis.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 1);

But it gave the following security permission exception [03-14 21:24:41.575: ERROR/DatabaseUtils(1066): java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS] even though I had added the following statement in AndroidMenifestFile.xml <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"></uses-permission>

So my question is:
- Was the above method is the right way to SWITCH OFF the screen
- How does the LONG END KEY press, switches/powers off the display? Which API it calls?
- How to SWITCH on? Is it using the PowerManager wakelock?

I appreciate and thankful for your time.

Regards,
-Arun


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate