I am currently writing an app that uses the Google's Activity Recognition API, however in my onHandleIntent method when I put a break point in there to examine the intent being passed in from the service, it is showing me stale data. The activity is returning as STILL even though I am on the road and even on the freeway. [FYI I am not driving but in a moving vehicle :) ] is there anyway to flush the results? even when I disconnect and reconnect I am still getting this STILL reading.
Asked
Active
Viewed 246 times
3
-
were you able to solve this, as it seems that I have the same issue with no solution – Kirill K Apr 18 '15 at 19:04
-
What I have noticed is for some reason my location services becomes disabled. When thus happens the STILL reading makes sense. Currently I am looking into a work around thst will alert the user that the location has been disabled and I am also trying to monitor if when the data become stale that it is in fact the location services is disabled – JenniferG Apr 19 '15 at 20:07
1 Answers
0
I thought I would share this on the off chance that it is a partial solution to the issue I described in my question. I have tweaked my code and it appears to not be having this issue at the moment. What I am doing to the intent being passed to the activity recognition is giving it a dynamic id, my theory is if i disconnect and reconnect it will is getting the same code to it maybe be caching the stale state. Now with my dynamic id, which really shouldn't hurt anything b/c the id only changes after the remove updates is called, I am hoping this will prevent the cached state.
private static void intentID(){
if(intentID == 0)
intentID = (int)(System.currentTimeMillis());
return intentID;
}
PendingIntent pendingIntent = PendingIntent.getService(mContext, intentID(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
//the modified pendingIntent being used
ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates(getActivityRecognitionClient(), 1000*10, pendingIntent)
hope this helps!

JenniferG
- 602
- 1
- 5
- 13