Search code examples
androideclipse-adtbrightness

Android Screen Brightness Lock


I am creating an android application that needs to keep the device awake (will not lock) like this:

enter image description here

please help me to add the "Screen light lock" check-box in my settings activity. (in java, adt bundle eclipse)

Sorry for my poor English.


Solution

  • in your manifest :

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    

    in your activity :

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.wakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK |     
    PowerManager.ON_AFTER_RELEASE, "My Tag");
    wakeLock.acquire();