I am trying to get the permission to access app usage data using this permission. THis is only being done for Lollipop and when I start activity with this intent (android.settings.USAGE_ACCESS_SETTINGS), the app crashes (stacktrace below)
Observed that another developer noticed this issue in LG G3 phone - thread here.From user logs, I have mostly seen this occur on LG G3 and once on Samsung S5 also.
What is the right intent to launch the window for LG & Samsung S3 phone to get app usage data?
Does someone have either of these phones and can advice if this "Apps using Usage Data" permission option even exists
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.USAGE_ACCESS_SETTINGS }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1801)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1499)
at android.app.Activity.startActivityForResult(Activity.java:3913)
at android.app.Activity.startActivityForResult(Activity.java:3860)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivi ty.java:849)
at android.support.v4.app.Fragment.startActivity(Fragment.java:880)
at com.mavdev.focusoutfacebook.fragments.addablock.apps.Fragment_appsselect_addbloc k$2.onClick(Fragment_appsselect_addblock.java:182)
at android.view.View.performClick(View.java:5162)
at android.view.View$PerformClick.run(View.java:20873)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Here is my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hidden"
android:installLocation="internalOnly"
android:versionCode="50"
android:versionName="2.0.5" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/MyActionBarTheme"
android:vmSafeMode="true" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
I dont have a real LG device (or even Samsung S3) with Lollipop on it to test. I am only testing in the Genymotion Emulator with Android 5.0 (API21) and it works fine.