-1

This exception is coming on my main activity:

java.lang.RuntimeException: Unable to pause activity:
java.lang.SecurityException: uid does not have android.permission.UPDATE_DEVICE_STATS

I have noticed that this is coming on Android 6.0.1 (Marshmallow) and device is Samsung Galaxy J7. When I researched about the permission UPDATE_DEVICE_STATS, I found out that this permission is needed by system apps.

Can anyone please guide me why this exception suddenly started to showing up as my app is running fine on other devices.

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
Shreyansh Jain
  • 141
  • 1
  • 1
  • 8

2 Answers2

0

In 6.0 and above you have to get the permissions dynamically not at the application install time you must check this link.Permission are of two types dangerous and non dangerous.

Sagar Gangawane
  • 1,985
  • 1
  • 12
  • 22
0

For Marshmallow and above android version you have to check whether the requested permission is accepted by user or not dynamically using following code:

ActivityCompat.requestPermissions();

You have to check each and every permissions runtime.

and ensure that you have defined following permission in your manifest:

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

not

<user-permission android:name="android.permission.GET_TASKS" >
</user-permission>

Another solution is to define targetSdkVersion bellow 23 in manifest file :

android:targetSdkVersion="21"
Anjali
  • 1
  • 1
  • 13
  • 20