Home » Android » how to Notifications need WAKE_LOCK in android?

how to Notifications need WAKE_LOCK in android?

Posted by: admin June 15, 2020 Leave a comment

Questions:

how to remove this error during download image and when Updating Notification.

java.lang.SecurityException: Neither user 10080 nor current process
has android.permission.WAKE_LOCK. at
android.os.Parcel.readException(Parcel.java:1425) at
android.os.Parcel.readException(Parcel.java:1379) at
android.os.IPowerManager$Stub$Proxy.acquireWakeLock(IPowerManager.java:326)
at
android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:309)
at android.os.PowerManager$WakeLock.acquire(PowerManager.java:300) at
android.app.NotificationManager.notify(NotificationManager.java:128)
at
android.app.NotificationManager.notify(NotificationManager.java:104)

How to&Answers:

for Wakelock permission in your android manifest file use

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

Answer:

A wake lock is a mechanism to indicate that your application needs to have the device stay on.

If you want to keep the screen on you required this permission.

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

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.

Fore more click Doc

Answer:

put all the uses-permission at the end of the manifest