forked from backtrace-labs/backtrace-unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBacktraceCrashHelper.java
More file actions
50 lines (42 loc) · 1.51 KB
/
BacktraceCrashHelper.java
File metadata and controls
50 lines (42 loc) · 1.51 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
package backtrace.io.backtrace_unity_android_plugin;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
public class BacktraceCrashHelper {
public void throwRuntimeException() {
Log.d("BacktraceCrashHelper", "Throwing runtime exception");
throw new RuntimeException("Unity-test: Uncaught JVM exception");
}
public void throwBackgroundJavaException() {
Log.d("BacktraceCrashHelper", "throwing an unhandled background java exception");
new Thread(new Runnable() {
@Override
public void run() {
int[] numbers = {10, 20, 30, 40};
Log.d("BacktraceCrashHelper", String.valueOf(numbers[5]));
}
}).start();
}
public static void StartAnr() {
Log.d("BacktraceCrashHelper", "Starting ANR");
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
public static void ThrowNativeException() {
Log.d("BacktraceCrashHelper", "Trying to throw native exception");
BacktraceCrashHelper.Inte
3481
rnalCall();
}
private static void InternalCall(){
int[] numbers = {10, 20, 30, 40};
Log.d("BacktraceCrashHelper", String.valueOf(numbers[5]));
}
}