i am using this permission in my app and working fine in all devices and also in Marhshmallow 6.0
device.
There no need to WAKE_LOCK
permission runtime because its normal permission but getting issue in Nougat 7.0
devices.
App getting crashed and error occur "java.lang.SecurityException: Neither user 10799 nor current process has android.permission.WAKE_LOCK"
on line wakelock.acquire();
How to fix that?
Use
<uses-permission android:name="android.permission.WAKE_LOCK" />
only, no extra code needed. Call acquire() to acquire the wake lock and force the device to stay on at the level that was requested when the wake lock was created.
Call release() when you are done and don't need the lock anymore. It is very important to do this as soon as possible to avoid running down the device's battery excessively.
Add all the uses-permission at the end of the manifest
Find the solution
As per my knowledge this is enough in Manifest file
<uses-permission android:name="android.permission.WAKE_LOCK"/>
For Screen continously ON write below logic
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With