Wednesday, December 30, 2015

Android Services

A Service is an application component that can perform long-running operations in the background and does not provide a user interface.

two forms

       - Started ( run in the background indefinitely )
       - Bounded ( client-server interface that allows components to interact )

- A service runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise). 


      Creating a Started Service

            - Service
            - IntentService

- The return value from onStartCommand() escribes how the system should continue the service in the event that the system kills it

  1. START_NOT_STICKY - do not recreate the service, unless there are pending intents to deliver. 
  2. START_STICKY - started with null when there is no pending request. delivers intent when there is pending request.
  3. START_REDELIVER_INTENT - recreate the service with the last intent that was delivered to the service

    Creating a Bound Service
           - Local Binder ( if the service is private to the app )
           - Messenger
           - AIDL

     AIDL
          - By default, AIDL supports the following data types:

  - All primitive types in the Java programming language (such as int, long, char, boolean, and so on)
  -  String, CharSequence, List, Map


Binder - Internal

 ( Source )

No comments:

Post a Comment