How can I send a PendingIntent
with a LocationResult
?
I wanted to use same PendingIntent
I setup for receiving location changes to also receive the last location.
See the last lines in the code:
// Create pending intent for a service which received location changes
Intent locationIntent = new Intent(getApplicationContext(), LocationIntentService.class);
PendingIntent pendingIntent = PendingIntent.getService(
getApplicationContext(),
0,
locationIntent,
PendingIntent.FLAG_UPDATE_CURRENT
);
// Start listening to location changes
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, pendingIntent);
// Get last location
Location lastLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
// Send last location
if(lastLocation != null) {
// How to send it to the pending intent?
// Result result = LocationResult.create( ... )
// pendingIntent.send(result)
}