Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我可以获得用户';在我的应用程序中没有活动识别权限的步骤?_Android_Google Fit - Fatal编程技术网

Android 为什么我可以获得用户';在我的应用程序中没有活动识别权限的步骤?

Android 为什么我可以获得用户';在我的应用程序中没有活动识别权限的步骤?,android,google-fit,Android,Google Fit,我正在制作一个应用程序,通过使用GoogleFit获取用户的步骤 这是代码 val readRequest = DataReadRequest.Builder() .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA) .build() Fitness.getHistoryClient(context, GoogleSignIn

我正在制作一个应用程序,通过使用GoogleFit获取用户的步骤

这是代码

val readRequest = DataReadRequest.Builder()
                .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)
                .build()

Fitness.getHistoryClient(context, GoogleSignIn.getLastSignedInAccount(context))
    .readData(readRequest)
    .addOnSuccessListener { dataReadResponse ->
        Log.d("onSuccess", dataReadResponse)
    }
在此文档中,需要
活动识别
权限。

这是检查许可证的代码

if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACTIVITY_RECOGNITION)
    != PackageManager.PERMISSION_GRANTED) {
    if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACTIVITY_RECOGNITION)) {
    // NOT_GRANTED
    } else {
    // REJECT
    }
} else {
// GRANTED
}
环境:

targetSdkVersion 29
compileSdkVersion 29
running device android10

implementation 'com.google.android.gms:play-services-fitness:16.0.1'

您是否检查了
dataReadResponse
中的内容?未经允许,我不知道此功能的行为。也许它返回了一个成功,但由于数据为空或数据中有错误(?)是的,我再次检查了它。如果没有活动识别权限,我将获得步骤计数<代码>2020-12-17 125步数我在应用程序设置中授予了权限。授予->未授予未授予->授予如果我允许一次,步骤计数是否可用?您是否检查了
dataReadResponse
中的内容?未经允许,我不知道此功能的行为。也许它返回了一个成功,但由于数据为空或数据中有错误(?)是的,我再次检查了它。如果没有活动识别权限,我将获得步骤计数<代码>2020-12-17 125步数我在应用程序设置中授予了权限。授予->未授予未授予->授予如果我允许一次,步骤计数是否可用?