WearOS, startExercision выдает ошибку «Отсутствует разрешение»Android

Форум для тех, кто программирует под Android
Anonymous
WearOS, startExercision выдает ошибку «Отсутствует разрешение»

Сообщение Anonymous »

Я разрабатываю приложение для Samsung Watch 6 (WearOS), используя API служб здравоохранения Android.
Несколько месяцев назад оно работало нормально. Возможно, WearOS обновилась, или это связано с библиотеками моего проекта, которые я обновил через несколько месяцев.
Когда я звоню:
healthServicesClient.exerciseClient.startExercise(config)

Я получаю следующую ошибку, в которой не указано какое разрешение:
java.lang.SecurityException: Missing permissions
at androidx.health.services.client.impl.internal.StatusCallback.onFailure(StatusCallback.kt:43)
at androidx.health.services.client.impl.internal.IStatusCallback$Stub.onTransact(IStatusCallback.java:74)
at android.os.Binder.execTransactInternal(Binder.java:1285)
at android.os.Binder.execTransact(Binder.java:1244)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@156f238, Dispatchers.Main.immediate]

Ниже приведены разрешения, установленные в манифесте:









Я также запрашиваю разрешения в своем фрагменте
permissionLauncher.launch(REQUIRED_PERMISSIONS)

Ниже приведена вся конфигурация, которую я установил для startExcercision(config)
val capabilities = getExerciseCapabilities() ?: return
val dataTypes = setOf(
DataType.HEART_RATE_BPM,
DataType.CALORIES_TOTAL,
DataType.STEPS_TOTAL,
DataType.DISTANCE
).intersect(capabilities.supportedDataTypes)

val exerciseGoals = mutableListOf()
if (supportsCalorieGoal(capabilities)) {
// Create a one-time goal.
exerciseGoals.add(
ExerciseGoal.createOneTimeGoal(
DataTypeCondition(
dataType = DataType.CALORIES_TOTAL,
threshold = CALORIES_THRESHOLD,
comparisonType = ComparisonType.GREATER_THAN_OR_EQUAL
)
)
)
}

if (supportsDistanceMilestone(capabilities)) {
// Create a milestone goal. To make a milestone for every kilometer, set the initial
// threshold to 1km and the period to 1km.
exerciseGoals.add(
ExerciseGoal.createMilestone(
condition = DataTypeCondition(
dataType = DataType.DISTANCE_TOTAL,
threshold = DISTANCE_THRESHOLD,
comparisonType = ComparisonType.GREATER_THAN_OR_EQUAL
),
period = DISTANCE_THRESHOLD
)
)
}

val config = ExerciseConfig(
exerciseType = ExerciseType.RUNNING,
dataTypes = dataTypes,
isAutoPauseAndResumeEnabled = false,
isGpsEnabled = true,
exerciseGoals = exerciseGoals
)
exerciseClient.startExercise(config)


Подробнее здесь: https://stackoverflow.com/questions/791 ... sion-error

Вернуться в «Android»