Table of Contents

Android Hacking Notes

Android Service

A Service is an application component that can perform long-running operations in the background. It does not provide a user interface. There are 3 kind of service:

  1. Foreground Service. A foreground service performs some operation that is noticeable to the user.
  2. Background Service. A background service performs an operation that isn't directly noticed by the user.
  3. Bound Service. A bound service offers a client-server interface that allows components to interact with the service, send requests, receive results, and even do so across processes with interprocess communication (IPC).

By default, service will run on the main/UI thread if we don't explicitly specify the worker thread.

Foreground Service

Background Service

Bound Service

A bound service runs only as long as another application component is bound to it. Multiple components can bind to the service at once, but when all of them unbind, the service is destroyed.

Fragment Lifecycle Event Sequence

  1. onAttach
  2. onCreate
  3. onCreateView
  4. onViewCreated
  5. onActivityCreated
  6. onViewStateRestored
  7. onStart
  8. onResume
  9. onPause
  10. onStop
  11. onDestroyView
  12. onDestroy
  13. onDetach

Background Thread

References