Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uses-permission android:name="android.permission.WAKE_LOCK permission issue

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?

like image 431
aj0822ArpitJoshi Avatar asked Mar 23 '17 05:03

aj0822ArpitJoshi


2 Answers

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

like image 180
Rahul Sharma Avatar answered Oct 07 '22 18:10

Rahul Sharma


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);
like image 20
Rajasekhar Avatar answered Oct 07 '22 19:10

Rajasekhar