Search code examples
androidbroadcastreceiverintentservice

BroadcastReceiver vs IntentService


I see BroadcastReceiver and IntentService are used in this code to listen to location updates. This is a sample from google, so I assume there should be a good reason for it. IF you look at LocationUpdatesBroadcastReceiver and LocationUpdatesIntentService , the contents are almost same. Is it because one work in background?


Solution

  • I am making it point to point and not covering extra info, because there are many changes recently with the App background behavior and location updates in foreground and background.

    In Android Oreo and above, when App goes to background, Intent Service cannot be started, whereas Broadcast receiver can be invoked.

    Note: The code linked by you is part of android code-labs tutorials, further explanation of your code can be found in https://codelabs.developers.google.com/codelabs/background-location-updates-android-o