Domanda

Currently i am working on my first android project.

When screen off led light also off any help guys.

È stato utile?

Soluzione

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();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top