Class DynamicAppMonitor
java.lang.Object
com.pranavpandey.android.dynamic.util.concurrent.DynamicRunnable<T,P,R>
com.pranavpandey.android.dynamic.util.concurrent.DynamicTask<Void,DynamicAppInfo,Void>
com.pranavpandey.android.dynamic.engine.task.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 Summary
Modifier and TypeFieldDescriptionstatic final long
The minimal period in milliseconds between two events. -
Constructor Summary
ConstructorDescriptionDynamicAppMonitor
(DynamicEngine dynamicEngine) Constructor to initialize an object of this class. -
Method Summary
Modifier and TypeMethodDescriptionprotected Void
doInBackground
(Void params) Get the current dynamic app info.boolean
Get the dormant status of this task.boolean
isPaused()
Get the paused status of this task.boolean
Get the running status of this task.void
This method will be called to notify for the accessibility event.protected void
protected void
onPostExecute
(DynamicResult<Void> result) protected void
protected void
onProgressUpdate
(DynamicResult<DynamicAppInfo> progress) void
setCurrentAppInfo
(DynamicAppInfo dynamicAppInfo) Set the current dynamic app info.void
setDormant
(boolean dormant) Set the dormant status of this task.void
setPaused
(boolean paused) Set the paused status of this task.void
setRunning
(boolean running) Set the running status of this task.Methods inherited from class com.pranavpandey.android.dynamic.util.concurrent.DynamicTask
cancel, execute, execute, executeOnExecutor, executeOnExecutor, finish, get, get, getBooleanResult, getHandler, getStatus, isCancelled, publishProgress, run
Methods inherited from class com.pranavpandey.android.dynamic.util.concurrent.DynamicRunnable
onCancelled
-
Field Details
-
ADE_NOTIFICATION_TIMEOUT
public static final long ADE_NOTIFICATION_TIMEOUTThe minimal period in milliseconds between two events.- See Also:
-
-
Constructor Details
-
Method Details
-
onPreExecute
protected void onPreExecute()- Overrides:
onPreExecute
in classDynamicRunnable<Void,
DynamicAppInfo, Void>
-
doInBackground
- Specified by:
doInBackground
in classDynamicRunnable<Void,
DynamicAppInfo, Void>
-
onCancelled
protected void onCancelled()- Overrides:
onCancelled
in classDynamicRunnable<Void,
DynamicAppInfo, Void>
-
onAccessibilityEvent
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
Get the current dynamic app info.- Returns:
- The current dynamic app info.
-