I had a code working that was using Google\'s Activity Recognition Updates. Now all of a sudden these seem to send updates either several times per second or never although requ
As suggested by canopi, increase the detection 'time', in which 0 will give you the fastest result.
I had encountered the same problem and instead of adding the build() part on onCreate directly, I added the method below and called it on onCreate(). Try to trace the code from this google sample. I got the code stripped down from there.
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(ActivityRecognition.API)
.build();
}
Also add buildGoogleApiClient()
to your onCreate method.
I would suggest you increase the detection interval, it takes at least 6 to 7 seconds for the sensors to detect a change in your activity. Also, I have observed that ActivityRecognition stops firing intents if the device is Still for a certain period of time. They are immediately triggered when the device is in motion again.
Perhaps you have the location services disabled on your Nexus 5 device...
Activity Recognition needs the location services active/enabled.