Skip to content

Commit fbf89a5

Browse files
Update README.md
1 parent ebf4e79 commit fbf89a5

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ public class App extends Application {
6969
```java
7070

7171

72+
final TextView textView = (TextView) findViewById(R.id.text);
73+
findViewById(R.id.install).setOnClickListener(new View.OnClickListener() {
74+
@Override
75+
public void onClick(View v) {
76+
textView.setText("已安装 Cockroach");
77+
install();
78+
}
79+
});
80+
81+
findViewById(R.id.uninstall).setOnClickListener(new View.OnClickListener() {
82+
@Override
83+
public void onClick(View v) {
84+
textView.setText("已卸载 Cockroach");
85+
Cockroach.uninstall();
86+
}
87+
});
88+
7289
findViewById(R.id.but1).setOnClickListener(new View.OnClickListener() {
7390
@Override
7491
public void onClick(View v) {
@@ -101,6 +118,38 @@ public class App extends Application {
101118
}
102119
});
103120

121+
findViewById(R.id.but4).setOnClickListener(new View.OnClickListener() {
122+
@Override
123+
public void onClick(View v) {
124+
startActivity(new Intent(getApplicationContext(), SecActivity.class));
125+
}
126+
});
127+
128+
}
129+
130+
private void install() {
131+
Cockroach.install(new Cockroach.ExceptionHandler() {
132+
@Override
133+
public void handlerException(final Thread thread, final Throwable throwable) {
134+
135+
Log.d("Cockroach", "MainThread: " + Looper.getMainLooper().getThread() + " curThread: " + Thread.currentThread());
136+
137+
new Handler(Looper.getMainLooper()).post(new Runnable() {
138+
@Override
139+
public void run() {
140+
try {
141+
142+
Log.e("AndroidRuntime","--->CockroachException:"+thread+"<---",throwable);
143+
Toast.makeText(getApplicationContext(), "Exception Happend\n" + thread + "\n" + throwable.toString(), Toast.LENGTH_SHORT).show();
144+
// throw new RuntimeException("..."+(i++));
145+
} catch (Throwable e) {
146+
147+
}
148+
}
149+
});
150+
}
151+
});
152+
}
104153

105154
```
106155

0 commit comments

Comments
 (0)