android.permission.ACTIVITY_RECOGNITION 尝试请求用户许可时未被识别
android.permission.ACTIVITY_RECOGNITION not getting recognized while trying to request for user permission
Google 当我尝试使用 RecordingClient (https://developers.google.com/android/reference/com/google/android/gms/fitness/RecordingClient)[=19 订阅 TYPE_STEP_COUNT_CUMULATIVE
(累积步骤)和 TYPE_STEP_COUNT_DELTA
时,Fit 给出了以下异常=]
failure: com.google.android.gms.common.api.ApiException: 10: SecurityException: com.google.step_count.cumulative requires android.permission.ACTIVITY_RECOGNITION
failure: com.google.android.gms.common.api.ApiException: 10: SecurityException: com.google.step_count.delta requires android.permission.ACTIVITY_RECOGNITION
这仅适用于 API 29 级及以上。
我尝试按照 的建议在清单中包含 <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
和 <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
但我无法请求 Main Activity.
的许可
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACTIVITY_RECOGNITION), REQUEST_CODE) // error occurs here
}
ACTIVITY_RECOGNITION 无法识别,我在输入时也没有将其作为建议。
Google 当我尝试使用 RecordingClient (https://developers.google.com/android/reference/com/google/android/gms/fitness/RecordingClient)[=19 订阅 TYPE_STEP_COUNT_CUMULATIVE
(累积步骤)和 TYPE_STEP_COUNT_DELTA
时,Fit 给出了以下异常=]
failure: com.google.android.gms.common.api.ApiException: 10: SecurityException: com.google.step_count.cumulative requires android.permission.ACTIVITY_RECOGNITION
failure: com.google.android.gms.common.api.ApiException: 10: SecurityException: com.google.step_count.delta requires android.permission.ACTIVITY_RECOGNITION
这仅适用于 API 29 级及以上。
我尝试按照 <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
和 <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
但我无法请求 Main Activity.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACTIVITY_RECOGNITION), REQUEST_CODE) // error occurs here
}
ACTIVITY_RECOGNITION 无法识别,我在输入时也没有将其作为建议。