Android 10 request permission for ACTIVITY_RECOGNITION

六月ゝ 毕业季﹏ 提交于 2020-06-28 10:18:42

问题


I'm trying to comply with the Google requirements to request the permission ACTIVITY_RECOGNITION, for Android 10, but I don't seem to understand why there's no permission popup showing , like with the other permissions (ie, Location, storage,...)

The code I have is:

 if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACTIVITY_RECOGNITION) != PackageManager.PERMISSION_GRANTED) {
        Log.d("TAG", "PERMISSION 'ACTIVITY_RECOGNITION' NOT GRANTED");

        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.ACTIVITY_RECOGNITION},
                MY_PERMISSIONS_ACTIVITY_RECOGNITION);
    } else
    {
        Log.d("TAG", "PERMISSION 'ACTIVITY_RECOGNITION' GRANTED");
    }

And I'm always ending up on the 'NOT GRANTED' flow, but the ActivityCompat.requestPermissions is not showing no popup! Is there anything else I'm Missing ?

The manifest contains the and the app.gradle minSdkVersion 29 targetSdkVersion 30

Running out of ideas, any help would be welcome. Just to add, I'm running this on my Pixel 2, with the latest firmware available 10.0.0 (QP1A.191105.004, Nov 2019)


回答1:


check : Privacy changes in Android 10

From API 29(Android Q, Android 10) Android App need permission in AndroidManifest.xml

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>

Before API 29 AndroidManifest.xml

<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />

check : Google Fit APIs

And

If the system-auto grants the android.permission.ACTIVITY_RECOGNITION permission, your app retains the permission after you update your app to target Android 10. However, the user can revoke this permission at any time in system settings.

Thanks.



来源:https://stackoverflow.com/questions/58958628/android-10-request-permission-for-activity-recognition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!