Interface DynamicEventListener

All Known Implementing Classes:
DynamicEngine

public interface DynamicEventListener
Interface to listen various system events with the help of DynamicEngine.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onAppChange(DynamicAppInfo dynamicAppInfo)
    This method will be called when the foreground app is changed.
    void
    onCallStateChange(boolean call)
    This method will be called when the call state is changed.
    void
    onChargingStateChange(boolean charging)
    This method will be called when the charging state is changed.
    void
    onDockStateChange(boolean docked)
    This method will be called when the dock state is changed.
    void
    onHeadsetStateChange(boolean connected)
    This method will be called when the headset state is changed.
    void
    onHingeStateChange(int state)
    This method will be called when the hinge state is changed.
    void
    onInitialize(boolean charging, boolean headset, boolean docked)
    This method will be called on initializing the service so that we can get the current charging, headset and dock state.
    void
    onLockStateChange(boolean locked)
    This method will be called when the lock state is changed.
    void
    onPackageRemoved(String packageName)
    This method will be called when an app package is removed.
    void
    onPackageUpdated(DynamicAppInfo dynamicAppInfo, boolean newPackage)
    This method will be called when an app package is added or changed.
    void
    onScreenStateChange(boolean screenOff)
    This method will be called when the screen state is changed.
  • Method Details

    • onInitialize

      void onInitialize(boolean charging, boolean headset, boolean docked)
      This method will be called on initializing the service so that we can get the current charging, headset and dock state.
      Parameters:
      charging - true if the device is charging or connected to a power source.
      headset - true if the device is connected to a headset or a audio output device.
      docked - true if the device is docked.
    • onHingeStateChange

      void onHingeStateChange(int state)
      This method will be called when the hinge state is changed.
      Parameters:
      state - The current hinge state.
      See Also:
    • onCallStateChange

      void onCallStateChange(boolean call)
      This method will be called when the call state is changed.

      Either on call or the device is idle.

      Parameters:
      call - true if the device is on call.

      Either ringing or answered.

    • onScreenStateChange

      void onScreenStateChange(boolean screenOff)
      This method will be called when the screen state is changed.

      Either the device screen is off or on.

      Parameters:
      screenOff - true if the device screen is off.
    • onLockStateChange

      void onLockStateChange(boolean locked)
      This method will be called when the lock state is changed.

      Either the device is in the locked or unlocked state independent of the PIN, password or any other security lock.

      Parameters:
      locked - true if the device is in the locked state or the lock screen is shown.
    • onHeadsetStateChange

      void onHeadsetStateChange(boolean connected)
      This method will be called when the headset state is changed.

      Either the device is connected to a audio output device or volume is routed through the internal speaker.

      Parameters:
      connected - true if the device is connected to a headset or a audio output device.
    • onChargingStateChange

      void onChargingStateChange(boolean charging)
      This method will be called when the charging state is changed.

      Either the device is connected to a power source using the battery.

      Parameters:
      charging - true if the device is charging or connected to a power source.
    • onDockStateChange

      void onDockStateChange(boolean docked)
      This method will be called when the dock state is changed.

      Either the device is docked or not.

      Parameters:
      docked - true if the device is docked.
    • onAppChange

      void onAppChange(@Nullable DynamicAppInfo dynamicAppInfo)
      This method will be called when the foreground app is changed.

      Use it to provide the app specific functionality in the app.

      Parameters:
      dynamicAppInfo - The dynamic app info of the foreground package.
    • onPackageUpdated

      void onPackageUpdated(@Nullable DynamicAppInfo dynamicAppInfo, boolean newPackage)
      This method will be called when an app package is added or changed.

      Useful to show a notification if an app is updated or a new app is installed.

      Parameters:
      dynamicAppInfo - The dynamic app info of the updated or added package.
      newPackage - true if the package is newly added.
    • onPackageRemoved

      void onPackageRemoved(@Nullable String packageName)
      This method will be called when an app package is removed.

      Useful to show some work when a package is removed.

      Parameters:
      packageName - The package which was removed.