Anyone have trouble with the Activity Recognition API in the recent Google Play Services update?
I have it implemented in an app. It was working perfectly fine before th
The main change is that ON_FOOT now returns a list of Detected Activities. Use getMostProbableActivities() instead now.
this solution gets walking or running when ON_foot get a list of Detected activities like this:
//Get the list from the result
ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
ArrayList activityList = new ArrayList(result.getProbableActivities());
//Get the most probable activity
getMostProbableActivity(activityList);
Now pass your list to find the most probable activity like this:
private DetectedActivity getMostProbableActivity(List detectedActivityList)
{
DetectedActivity result = null;
//Find the most probably activity in the list
for(DetectedActivity detectedActivity : detectedActivityList)
{
if(detectedActivity.getType() != DetectedActivity.ON_FOOT)
{
if(result == null)
{
result = detectedActivity;
}
else
{
if(result.getConfidence() < detectedActivity.getConfidence())
{
result = detectedActivity;
}
}
}
}
return result;
}