How to check if “android.permission.PACKAGE_USAGE_STATS” permission is given?
问题 Background I'm trying to get app-launched statistics, and on Lollipop it's possible by using the UsageStatsManager class, as such (original post here): manifest: <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions"/> opening the activity that will let the user confirm giving you this permission: startActivity(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)); getting the stats, aggregated : private static final String USAGE_STATS_SERVICE