Class DynamicStickyService

All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2
Direct Known Subclasses:
DynamicEngine

public abstract class DynamicStickyService extends AccessibilityService
Sticky service which will restart automatically if killed by the system.

Useful in low memory or similar situations where we need to run the service continuously in the background.

  • Field Details

    • ADE_DEFAULT_RESTART_INTERVAL

      public static final long ADE_DEFAULT_RESTART_INTERVAL
      Default interval after which try to restart the service.
      See Also:
  • Constructor Details

    • DynamicStickyService

      public DynamicStickyService()
  • Method Details

    • onCreate

      public void onCreate()
      Overrides:
      onCreate in class Service
    • onStartCommand

      public int onStartCommand(@Nullable Intent intent, int flags, int startId)
      Overrides:
      onStartCommand in class Service
    • getRestartInterval

      protected long getRestartInterval()
      Get restart interval after which try to restart the service.

      Override this method in the extended class to change the default interval.

      Returns:
      The Interval in milliseconds after which service will be restarted.
      See Also:
    • onAccessibilityEvent

      public void onAccessibilityEvent(AccessibilityEvent event)
      Specified by:
      onAccessibilityEvent in class AccessibilityService
    • onServiceConnected

      protected void onServiceConnected()
      Overrides:
      onServiceConnected in class AccessibilityService
    • onInterrupt

      public void onInterrupt()
      Specified by:
      onInterrupt in class AccessibilityService
    • onAccessibilityStateChanged

      protected void onAccessibilityStateChanged(boolean enabled)
      Called back on change in the accessibility state.
      Parameters:
      enabled - Whether accessibility is enabled.