是否可以为ActivityRecognitionApi模拟检测到的活动以进行测试? [英] Is it possible to simulate detected activities for the ActivityRecognitionApi for testing purposes?

查看:120
本文介绍了是否可以为ActivityRecognitionApi模拟检测到的活动以进行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Play服务提供了 ActivityRecognitionApi ,可让您检测各种用户活动(通过 DetectedActivity ),例如,如果用户是步行正在运行

Google Play Services provides an ActivityRecognitionApi that lets you detect various user activities (via DetectedActivity) such as if the user is walking or running.

是否可以模拟这些活动出于开发和测试目的?

Is it possible to mock these activities for development and testing purposes?

推荐答案

是的,有可能,但只能在仿真器(或有根设备)上使用。

Yes, it's possible, but only on the emulator (or a rooted device).

例如,模拟步入g活动运行:

For example, to simulate the walking activity run:

adb root
adb shell am broadcast -a com.google.gservices.intent.action.GSERVICES_OVERRIDE -e 'location:mock_activity_type' 'WALKING'

然后重新启动Google Play服务(或重新启动设备):

And then restart Google Play Services (or restart the device):

adb shell ps -A | grep com.google.android.gms.persistent | awk '{print $2}' | xargs adb shell kill

这篇关于是否可以为ActivityRecognitionApi模拟检测到的活动以进行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆