I'm trying to use the activity recognition in a project to detect when the user is "IN-VEHICLE".(Driving) The problem is that it is almost impossibly to use it, as mostProbableActivity often report "IN-VEHICLE" even though I've been sitting at my desk for a long time or just walking around in my house. It would be very nice to know how the API conclude this.
I think this feature has great potential, but as now something is clearly not working.
This is a log of MostProbableActivity taken every 30 seconds to show what I mean. Sitting at my desk, after 4 minutes I turn the phone a couple of times, and this results in a "mostProbable IN-VEHICLE" result.
I've tried different phones and the result is the same. So I don't think it's hardware related.
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]
This is the code, nothing special there:
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));
}
}
From this link:
I can see that others have similar experience, but some claims that it works OK.
I think this is a bug in the confidence algorithm of the API. It should be easy to conclude that the phone isn't moving in any direction, nor on a road so obviously NOT "mostProbable" in a VEHICLE.
Can anyone confirm this problem or do I use it the wrong way?
Best regards
Thomas