0

Android Lollipop has provided the UsageStatsManager service which allows apps to get information about device usage statistics, as long as the user of the device has granted the required permission through the Settings.

Is it possible to find out programmatically if the user has granted us the permission?

Thanks.

Pin
  • 3,746
  • 4
  • 26
  • 33
  • http://stackoverflow.com/questions/27215013/check-if-my-application-has-usage-access-enabled But this works only for Nexus devices. Does not work in LG , HTC . – Senthil Kumar Jun 12 '15 at 06:32

1 Answers1

1

You can just check the size of the list returned from UsageStatsManager.queryUsageStats. If the user has not granted permission, the list will be empty.

dannyhan12
  • 942
  • 8
  • 9
  • 1
    This is what we're doing right now, but I was expecting a better API to be honest... – Pin Nov 29 '14 at 16:49