-1

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.

2 Answers2

1

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();
Decoy
  • 1,598
  • 12
  • 19
-1

If you meant, you need to keep the device awake (will not lock), At the onCreate use this line of code:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

for knowing better see this: https://developer.android.com/training/scheduling/wakelock.html

David
  • 39
  • 4