Tell us how would you update the UI of an activity from a background service?

Submitted by: Muhammad
We need to register a LocalBroadcastReceiver in the activity. And send a broadcast with the data using intents from the background service. As long as the activity is in the foreground, the UI will be updated from the background. Ensure to unregister the broadcast receiver in the onStop() method of the activity to avoid memory leaks. We can also register a Handler and pass data using Handlers.
Submitted by: Muhammad

Read Online Android Developer Job Interview Questions And Answers