Search code examples
androidandroid-serviceandroid-a11y

Android - Accessibility service VS Background service


What is the difference between accessibility service and background service? When should I use each other?


Solution

  • The two serve different purposes entirely:

    Background Service - Unless you specify otherwise, most of the operations you do in an app run in the foreground on a special thread called the UI thread. This can cause problems, because long-running operations will interfere with the responsiveness of your user interface. This annoys your users, and can even cause system errors. The Androind framework allows you to run these sorts of operations in a background thread.

    Accessibility - Many Android users have different abilities that require them to interact with their Android devices in different ways. These include users who have visual, physical or age-related limitations that prevent them from fully seeing or using a touchscreen, and users with hearing loss who may not be able to perceive audible information and alerts.

    An accessibility service runs in the background and receives callbacks by the system when AccessibilityEvents are fired. Such events denote some state transition in the user interface, for example, the focus has changed, a button has been clicked, etc. Such a service can optionally request the capability for querying the content of the active window. Development of an accessibility service requires extending this class and implementing its abstract methods.

    Use accessibility if you think users will need special assistance with your app. Use background for long running tasks to keep your UI snappy.