Question

Currently i am working on my first android project.

When screen off led light also off any help guys.

Was it helpful?

Solution

When your flashlight app is running condition, Do this

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

Or you can do this, Wake Lock first Add this in your manifest

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

then,

 final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,"");    
   mWakeLock.acquire();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top