Class DynamicAppMonitor

All Implemented Interfaces:
Runnable

@RestrictTo(LIBRARY_GROUP) public class DynamicAppMonitor extends DynamicTask<Void,DynamicAppInfo,Void>
A DynamicTask to monitor foreground to provide app specific functionality.

Package must be granted Manifest.permission.PACKAGE_USAGE_STATS permission to detect the foreground app on API 21 and above.

  • Field Details

    • ADE_NOTIFICATION_TIMEOUT

      public static final long ADE_NOTIFICATION_TIMEOUT
      The minimal period in milliseconds between two events.
      See Also:
  • Constructor Details

    • DynamicAppMonitor

      public DynamicAppMonitor(@NonNull DynamicEngine dynamicEngine)
      Constructor to initialize an object of this class.
      Parameters:
      dynamicEngine - The dynamic engine using which is using this task.
  • Method Details

    • onPreExecute

      protected void onPreExecute()
      Overrides:
      onPreExecute in class DynamicRunnable<Void,DynamicAppInfo,Void>
    • doInBackground

      protected Void doInBackground(@Nullable Void params)
      Specified by:
      doInBackground in class DynamicRunnable<Void,DynamicAppInfo,Void>
    • onProgressUpdate

      protected void onProgressUpdate(@Nullable DynamicResult<DynamicAppInfo> progress)
      Overrides:
      onProgressUpdate in class DynamicRunnable<Void,DynamicAppInfo,Void>
    • onPostExecute

      protected void onPostExecute(@Nullable DynamicResult<Void> result)
      Overrides:
      onPostExecute in class DynamicRunnable<Void,DynamicAppInfo,Void>
    • onCancelled

      protected void onCancelled()
      Overrides:
      onCancelled in class DynamicRunnable<Void,DynamicAppInfo,Void>
    • onAccessibilityEvent

      public void onAccessibilityEvent(@Nullable AccessibilityEvent event)
      This method will be called to notify for the accessibility event.
      Parameters:
      event - The accessibility event.
    • isRunning

      public boolean isRunning()
      Get the running status of this task.
      Returns:
      true if this task is running.
    • setRunning

      public void setRunning(boolean running)
      Set the running status of this task.
      Parameters:
      running - true if this task is running.
    • isPaused

      public boolean isPaused()
      Get the paused status of this task.
      Returns:
      true if this task is paused.
    • setPaused

      public void setPaused(boolean paused)
      Set the paused status of this task.
      Parameters:
      paused - true if this task is paused.
    • isDormant

      public boolean isDormant()
      Get the dormant status of this task.
      Returns:
      true if this task is dormant.
    • setDormant

      public void setDormant(boolean dormant)
      Set the dormant status of this task.
      Parameters:
      dormant - true if this task is dormant.
    • getCurrentAppInfo

      @Nullable public DynamicAppInfo getCurrentAppInfo()
      Get the current dynamic app info.
      Returns:
      The current dynamic app info.
    • setCurrentAppInfo

      public void setCurrentAppInfo(@Nullable DynamicAppInfo dynamicAppInfo)
      Set the current dynamic app info.
      Parameters:
      dynamicAppInfo - The current dynamic app info to be set.