Maybe there's something really simple that I don't see. I'm trying to call a method from some API, and this method asks for a PendingIntent to send me asynchronously some value. I've read the doc and examples for half an hour, and can't wrap my head around a simple way to do it.
More precisely, I want to call the ActivityRecognitionApi. To illustrate, here's how I receive the location from a similar api:
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient,
mLocationRequest,
new LocationListener() {
@Override
public void onLocationChanged(Location location) {
// I can do something with the location
}
});
So I want to do the same to receive the recognized activity :
ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates(mGoogleApiClient,
1000,
// ... what here ?);
So what would be the simple way to create a pendingIntent to just receive the value ? I tried to create an anonymous PendingIntent but the class is final. I don't want to start a Service, or Activity, or broadcast anything... Is there just a simple way to create this PendingIntent to execute just a block of code?
Thanks in advance,