0

I want to put my phone in dim mode using my application. It seems phone's home screen will be in deem mode. If I going to use Power Manager class then it will drain battery. How can I do this then? Can any one give some sample code?

1 Answer 1

1

In my case I just update the Android Default Settings,

android.provider.Settings.System.putInt(cr,android.provider.Settings.System.SCREEN_BRIGHTNESS, 1);

Note: here 1 is value for dim (low) (values 0 t0 250) , and cr is ContentResolver's object

For this you have to mentioned permission in manifest file,

 <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
8
  • the code is right but Google hides some API so the code won't take effect until you turn off the screen and then turn on once.
    – Huang
    Nov 3, 2011 at 9:53
  • actually,you can set the value from 0 to 255
    – Huang
    Nov 3, 2011 at 9:54
  • @Huang - Thanks for comment, I am using this in my galaxy tab and I don't get any difficulty(as you mentioned) till now. Its work fine.
    – user370305
    Nov 3, 2011 at 9:56
  • on my Motorola phone, the code works that way.Perhaps depends on the rom. But I don't think it is like a SCREEN LOCK , since the screen still responds to the touch event.
    – Huang
    Nov 3, 2011 at 10:02
  • @Huang - yes you are right, in 0 its also worked. Sorry for that comment. Actually I had a problem in manage that value.
    – user370305
    Nov 3, 2011 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.