You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android 14下Activity Recognition对应的前台服务类型选择

ActivityRecognition功能适配Android 14前台服务类型的选择

针对你的问题,直接给出结论:应选择location作为foregroundServiceType。

原因很明确:ActivityRecognition(活动识别)本质属于位置上下文感知功能,Google将其归类为位置相关范畴,而非健康类场景。health类型的前台服务主要用于心率、血氧、专业健康监测这类直接关联健康数据的功能,而活动识别(比如检测步行、骑行、静止等状态)核心依赖位置传感器的上下文判断,完全匹配location类型的适用场景。

修改后的清单文件服务代码如下:

<service
        android:name=".tracking.monitor.BackgroundDetectedActivitiesService"
        android:enabled="true"
        android:exported="false"
        android:permission="com.google.android.gms.permission.ACTIVITY_RECOGNITION"
        android:foregroundServiceType="location" />

内容的提问来源于stack exchange,提问作者alexC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 03:52:01