Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 11: Developing Background Servic... > Communicating with the UI

Communicating with the UI

In most apps, a service isn't much use unless it can communicate with the user interface to let it know when changes or updates have occurred. With Android, you should consider that the user interface is responsible for communicating with the service, because at any given time your activity may not be in the foreground. Consider that your service may be running and have new data to share with an activity at any time, but it would be a waste of resources trying to update an activity if it's paused or has been destroyed. A number of methods can be used to communicate with services:

  • Binding with the binder and service connection
  • Using a broadcast receiver when the activity is active
  • Registering for a static event in the activity

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint