3

in my jetpack compose wear app I'm trying to get the usage time of the user. I know that I have to <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions" /> in my manifest.

I also wrote the following code to open the screen where the user can give the needed usage access permission.

        val appOps = getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
        val mode = appOps.checkOpNoThrow("android:get_usage_stats", android.os.Process.myUid(), packageName)
        val granted = mode == AppOpsManager.MODE_ALLOWED

        if (!granted) {
            Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS).apply {
                startActivity(this)
            }
        }

On my simulated wearable device the wanted permission screen opens, but on my Galaxy Watch 4 nothing like that opens. I cant even find these permissions manually in the settings (neither on the simulator, nor the real watch).

Can anyone help me out?

Edit: I read a comment that said usage access is not available on wearos, can anyone confirm? Edit2: The settings app opens, but shows a blackscreen and closes immediately afterwards.

0

1 Answer 1

1

From https://developer.android.com/about/versions/12/reference/common-intents-31,

this isn't defined as supported on Wear.

android.settings.USAGE_ACCESS_SETTINGS
Handheld, Television, Tablet, Automotive

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.