Error in Manifest.xml when adding PACKAGE_USAGE_STATS [Android Lollipop]
Asked Answered
F

3

3

I am trying to use "android.permission.PACKAGE_USAGE_STATS" in my app. Here it says that NOTE: This API requires the permission android.permission.PACKAGE_USAGE_STATS, which is a system-level permission and will not be granted to third-party apps. However, declaring the permission implies intention to use the API and the user of the device can grant permission through the Settings application.

enter image description here

It seems that I will need the user to explicitly give my app the permission to give access to the access the usage stats.

In addition, I used the intent code below to open the screen to allow user to give access to my app, but my app is not in the list. Code I used:

Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
startActivity(intent);

When *startActivity(intent)' is fired (or going to *Settings>Security>Apps with Usage Access), a blank screen below pops up, my app is not part of it. enter image description here

Bottom line question is -- How to use UsageStatsManager in Android Lollipop? Anyone tried it?

Fibered answered 24/11, 2014 at 4:10 Comment(0)
L
1

The AndroidManifest.xml error can be fixed by disabling lint errors. Specifically

Security - SignatureorSystemPermissions 

I guess after that the settings app will show your app.

Lotty answered 24/11, 2014 at 4:41 Comment(3)
I have ignored the above permission in my application but still I facing the same alert. How do I overcome?Apeldoorn
@Rajsundar - the permission needs be ignored in Eclipse Settings in Lint.Fibered
@Fibered Thanks for your response, yeah I have ignored the in lint.Apeldoorn
P
9

This is what worked for me.

<uses-permission xmlns:tools="http://schemas.android.com/tools"
    android:name="android.permission.PACKAGE_USAGE_STATS"
    tools:ignore="ProtectedPermissions" />
Piecemeal answered 6/10, 2015 at 13:53 Comment(0)
C
8

You can simply make this on the manifest, ignoring just this permission error:

<uses-permission
    android:name="android.permission.PACKAGE_USAGE_STATS"
    tools:ignore="ProtectedPermissions"/>
Cogitate answered 7/3, 2015 at 23:12 Comment(0)
L
1

The AndroidManifest.xml error can be fixed by disabling lint errors. Specifically

Security - SignatureorSystemPermissions 

I guess after that the settings app will show your app.

Lotty answered 24/11, 2014 at 4:41 Comment(3)
I have ignored the above permission in my application but still I facing the same alert. How do I overcome?Apeldoorn
@Rajsundar - the permission needs be ignored in Eclipse Settings in Lint.Fibered
@Fibered Thanks for your response, yeah I have ignored the in lint.Apeldoorn

© 2022 - 2024 — McMap. All rights reserved.