我试图在项目中使用活动识别来检测用户何时是“车内”(驾驶)问题在于它几乎不可能使用它,因为大多数ProbableActivity经常报告“车内”(In-VEHICLE)尽管我已经坐在办公桌上很长时间,或者只是在我家里走动。知道API如何得出这个结论将是非常好的。活动识别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]
这是代码,没有什么特别的有:
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));
}
}
从这个链接:
我可以看到其他人有类似的经历,但有些说法,它行得通。
我认为这是API的置信算法中的一个错误。应该很容易得出这样的结论:手机没有朝任何方向移动,也没有在道路上显然不是“最可能的”。
任何人都可以证实这个问题,或者我用它错误的方式吗?
问候
托马斯
您正在以正确的方式使用它。问题在于,如果没有对GPS进行采样并排空电池,将很难检测到驾驶活动。 Google可能会在某些时段追踪传感器数据(加速度计,陀螺仪,磁力计等),并寻找驾驶模式(这与静止但非常相似,但具有独特的振动)。有时候算法不够精确。 – MikeL