-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatchdog.java
More file actions
72 lines (69 loc) · 2.31 KB
/
Copy pathwatchdog.java
File metadata and controls
72 lines (69 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package watchdog;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BA.DependsOn;
import com.github.anrwatchdog.ANRError;
import com.github.anrwatchdog.ANRWatchDog;
@Version(1.0f)
@ShortName("ANRWatchDog")
@DependsOn(values={"anrwatchdog-1.3.0"})
public class watchdog{
/**
* Constructs a watchdog that checks the ui thread every 5 seconds
* it logs the ANR error and closes the app
*/
public void start(){
new ANRWatchDog().start();
}
/**
* Constructs a watchdog that checks the ui thread every given interval
*
* @param 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 void startdelay(int t){
new ANRWatchDog(t).start();
}
/**
* Set whether to ignore the debugger when detecting ANRs.
* When ignoring the debugger, ANRWatchdog will detect ANRs even if the debugger is connected.
* By default, it does not, to avoid interpreting debugging pauses as ANRs.
* Default false.
*
* @param ignoreDebugger Whether to ignore the debugger.
* @return itself for chaining.
*/
public void IgnoreDebugger(){
new ANRWatchDog().setIgnoreDebugger(true).start();
}
/**
* Set that only the main thread will be reported.
*
* @return itself for chaining.
*/
public void MainThreadOnly(){
new ANRWatchDog().setReportMainThreadOnly().start();
}
/**
* Set the prefix that a thread's name must have for the thread to be reported.
* Note that the main thread is always reported.
*
* @param prefix The thread name's prefix for a thread to be reported.
* @return itself for chaining.
*/
public void ReportByThreadName(String a){
new ANRWatchDog().setReportThreadNamePrefix(a).start();
}
/**
* Set that all running threads will be reported,
* even those from which no stack trace could be extracted.
* Default false.
*
* @param logThreadsWithoutStackTrace Whether or not all running threads should be reported
* @return itself for chaining.
*/
public void setLogThreadsWithoutStackTrace(boolean b) {
new ANRWatchDog().setLogThreadsWithoutStackTrace(b).start();
}
}