活动识别API不可靠?

use*_*558 7 android android-sensors google-play-services

我正在尝试在项目中使用活动识别来检测用户何时是"车内".(驾驶)问题是几乎不可能使用它,因为大多数可行活动经常报告"车内"即使我一直坐在办公桌前很长一段时间,或者只是在我家里走来走去.知道API如何结束这将是非常好的.

我认为这个功能有很大的潜力,但是现在显然没有用.

这是每30秒拍摄一次MostProbableActivity的日志,以显示我的意思.坐在我的办公桌前,4分钟后我转了几次手机,这导致了"最具可驾驶性的车辆"结果.

我尝试过不同的手机,结果是一样的.所以我不认为它与硬件有关.

DetectedActivity [type=STILL, confidence=43]
DetectedActivity [type=STILL, confidence=54]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=69]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=92]
DetectedActivity [type=TILTING, confidence=100]
DetectedActivity [type=IN_VEHICLE, confidence=49]
DetectedActivity [type=TILTING, confidence=100]
DetectedActivity [type=STILL, confidence=51]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=85]
DetectedActivity [type=STILL, confidence=100]
DetectedActivity [type=STILL, confidence=66]
DetectedActivity [type=STILL, confidence=100]
Run Code Online (Sandbox Code Playgroud)

这是代码,没有什么特别之处:

public class ActivitiesIntentService extends IntentService {


    private static final String TAG = "ActivitiesIntentService";


    public ActivitiesIntentService() {
        super(TAG);
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
        Intent i = new Intent(Constants.STRING_ACTION);


        DetectedActivity mostProbableActivity = result.getMostProbableActivity();


        i.putExtra("MOST_PROBABLE_ACTIVITY",mostProbableActivity);



        LocalBroadcastManager.getInstance(this).sendBroadcast(i);


        Log.e(TAG, String.valueOf(mostProbableActivity));
        }

}
Run Code Online (Sandbox Code Playgroud)

从这个链接:

活动识别API

我可以看到其他人有类似的经历,但有些人声称它的工作正常.

我认为这是API置信度算法中的一个错误.应该很容易得出结论,手机没有向任何方向移动,也没有在道路上移动,所以显然不是车辆中的"最具可能性".

任何人都可以确认这个问题,还是以错误的方式使用它?

最好的祝福

托马斯

Dou*_*son 5

请记住,这是一种非常低能耗的服务,因此不能不断地查看设备传感器.这会使电池耗尽太快而无法使用.请务必阅读文档以了解约束.

如果您想要更准确的读数,请增加检测间隔.这将为其提供更多数据.

另外请记住,这些测量应该广泛采用.可能的用例是估计设备的运营商参与物理活动的时间,或者当运营商正在执行检测到的活动之一时激活和停用应该运行的应用程序的组件.