- Started state
- Started seems pretty self explanatory; it just means that the service has begun so that could maybe mean that an individual just started playing music while looking at their email. Also, the music will continue even if they close their email so services can continue as long as they are not specifically closed.
- Bound state
- I don't really understand this but I'm guessing if a service is bound then the app is retrieving data of some sort so text messaging may have a service to retrieve texts for a person to read. Below is a diagram of the process of started and bound services along with their functions.
onStartCommand():Obviously starts the service and it's very important to put in a method to stop it, either stopSelf() or stopService(). Also requires an interface to be implemented for use by the client.onBind():This method is always required when implementing a service but it's possible to still prevent binding(I'm still a bit confused on this and the other binding methods).
onUnbind():Called when all clients are no longer using a service.
onRebind():Used when clients have reconnected to a service.
onCreate():Called to create the service.onDestroy():Called to destroy the service and any resources related to it.
Thursday, October 16, 2014
Android Tutorial Chapter 8
This chapter focused on services which I think I briefly talked about before but a service allows for an operation to be running for a long time in the background of an app such as music or retrieving data. There are also two states to a service started and bound.
Subscribe to:
Post Comments (Atom)
Whenever you say to yourself, "I don't really understand this...", take some time and try to research it (beyond just the one tutorial you are using as your primary resource) on the web. Does Wikipedia have anything to say? What other resources besides your current tutorial might be helpful. Make a list of them in a blog post next week.
ReplyDeleteIt is understanding the underlying concepts that will help you become and Android developer. Do not rush by things that you don't understand. You will soon find yourself completely lost in a strange world unless you proceed deliberately step-by-step, concept-by-concept and don't move on until you grasp what you have read.