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
FieldsModifier and TypeFieldDescriptionstatic final longThe minimal period in milliseconds between two events. -
Constructor Summary
ConstructorsConstructorDescriptionDynamicAppMonitor(DynamicEngine dynamicEngine) Constructor to initialize an object of this class. -
Method Summary
Modifier and TypeMethodDescriptionprotected VoiddoInBackground(Void params) Get the current dynamic app info.booleanGet the dormant status of this task.booleanisPaused()Get the paused status of this task.booleanGet the running status of this task.voidThis method will be called to notify for the accessibility event.protected voidprotected voidonPostExecute(DynamicResult<Void> result) protected voidprotected voidonProgressUpdate(DynamicResult<DynamicAppInfo> progress) voidsetCurrentAppInfo(DynamicAppInfo dynamicAppInfo) Set the current dynamic app info.voidsetDormant(boolean dormant) Set the dormant status of this task.voidsetPaused(boolean paused) Set the paused status of this task.voidsetRunning(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, runMethods 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:
onPreExecutein classDynamicRunnable<Void,DynamicAppInfo, Void>
-
doInBackground
- Specified by:
doInBackgroundin classDynamicRunnable<Void,DynamicAppInfo, Void>
-
onCancelled
protected void onCancelled()- Overrides:
onCancelledin 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:
trueif this task is running.
-
setRunning
public void setRunning(boolean running) Set the running status of this task.- Parameters:
running-trueif this task is running.
-
isPaused
public boolean isPaused()Get the paused status of this task.- Returns:
trueif this task is paused.
-
setPaused
public void setPaused(boolean paused) Set the paused status of this task.- Parameters:
paused-trueif this task is paused.
-
isDormant
public boolean isDormant()Get the dormant status of this task.- Returns:
trueif this task is dormant.
-
setDormant
public void setDormant(boolean dormant) Set the dormant status of this task.- Parameters:
dormant-trueif this task is dormant.
-
getCurrentAppInfo
Get the current dynamic app info.- Returns:
- The current dynamic app info.
-