Reputation: 317
My app requires regular updates of the user's location, in order to display them on a GoogleMap .
To achieve this I am using the LocationServices.FusedLocationApi.requestLocationUpdates() method, with the results being sent to a specified PendingIntent.
The Intent of the PendingIntent is a BroadcastReceiver, whose onReceive() method will process the results.
My question is: Do I need to invoke sendBroadcast() somewhere in order for the results to be received by the broadcast receiver, and if so, where?
Or, is it sufficient to have the PendingIntent with an Intent to a BroadcastReceiver for the results to get where they need to?
Upvotes: 1
Views: 844
Reputation: 43344
Do I need to invoke sendBroadcast() somewhere in order for the results to be received by the broadcast receiver, and if so, where?
No, you don't have to do that.
If you look at the javadoc for PendingIntent.getBroadcast()
you will see
Retrieve a PendingIntent that will perform a broadcast, like calling Context.sendBroadcast().
Or, is it sufficient to have the PendingIntent with an Intent to a BroadcastReceiver for the results to get where they need to?
Yes, that is enough, but note that you need to use PendingIntent.getBroadcast()
.
Upvotes: 2