When is it recommended to request a PendingIntent or LocationListener for a request of LocationUpdates?

You can subscribe to requestLocationUpdates in two ways.

  • one by specifying PendingIntent
  • another using LocationListener

When is one and the other advised?

+4
source share
1 answer

If a component that needs to be updated with a location needs only updates when the component is around - say, activity - I would use the LocationListener approach.

If the component in need of location updates would definitely not be around - say, IntentService - I would use PendingIntent . You cannot use the LocationListener in this case, since there is nothing in memory to listen to locations.

+6
source

Source: https://habr.com/ru/post/1313922/


All Articles