Android Developer Question:
Download Questions PDF

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

Android Developer Interview Question
Android Developer Interview Question

Answer:

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.

Download Android Developer Interview Questions And Answers PDF

Previous QuestionNext Question
What is access data using Content Provider:Explain me what is Android SDK?