public class ANRWatchDog
extends java.lang.Thread
Modifier and Type | Class and Description |
---|---|
static interface |
ANRWatchDog.ANRListener |
static interface |
ANRWatchDog.InterruptionListener |
Constructor and Description |
---|
ANRWatchDog()
Constructs a watchdog that checks the ui thread every milliseconds
|
ANRWatchDog(int timeoutInterval)
Constructs a watchdog that checks the ui thread every given interval
|
Modifier and Type | Method and Description |
---|---|
void |
run() |
ANRWatchDog |
setANRListener(ANRWatchDog.ANRListener listener)
Sets an interface for when an ANR is detected.
|
ANRWatchDog |
setIgnoreDebugger(boolean ignoreDebugger)
Set whether to ignore the debugger when detecting ANRs.
|
ANRWatchDog |
setInterruptionListener(ANRWatchDog.InterruptionListener listener)
Sets an interface for when the watchdog thread is interrupted.
|
ANRWatchDog |
setLogThreadsWithoutStackTrace(boolean logThreadsWithoutStackTrace)
Set that all running threads will be reported,
even those from which no stack trace could be extracted.
|
ANRWatchDog |
setReportMainThreadOnly()
Set that only the main thread will be reported.
|
ANRWatchDog |
setReportThreadNamePrefix(java.lang.String prefix)
Set the prefix that a thread's name must have for the thread to be reported.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public ANRWatchDog()
public ANRWatchDog(int timeoutInterval)
timeoutInterval
- The interval, in milliseconds, between to checks of the UI thread.
It is therefore the maximum time the UI may freeze before being reported as ANR.public ANRWatchDog setANRListener(ANRWatchDog.ANRListener listener)
listener
- The new listener or nullpublic ANRWatchDog setInterruptionListener(ANRWatchDog.InterruptionListener listener)
listener
- The new listener or null.public ANRWatchDog setReportThreadNamePrefix(java.lang.String prefix)
prefix
- The thread name's prefix for a thread to be reported.public ANRWatchDog setReportMainThreadOnly()
public ANRWatchDog setLogThreadsWithoutStackTrace(boolean logThreadsWithoutStackTrace)
logThreadsWithoutStackTrace
- Whether or not all running threads should be reportedpublic ANRWatchDog setIgnoreDebugger(boolean ignoreDebugger)
ignoreDebugger
- Whether to ignore the debugger.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread