Skip to content

Commit

Permalink
add: 信号量crash catch
Browse files Browse the repository at this point in the history
  • Loading branch information
zjw committed Jul 1, 2022
1 parent e8a698f commit 609f854
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/src/main/java/com/example/ndk/ndkdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
Expand All @@ -20,9 +21,17 @@ protected void onCreate(Bundle savedInstanceState) {

TextView tv_show = (TextView) findViewById(R.id.tv_show);
tv_show.setText(SignHelper.getSign(this));
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
//只能处理java层crash
Log.e("TAG","uncaughtException");
}
});
tv_show.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// int a = 1 / 0;
SignHelper.throwNativeCrash();
}
});
Expand Down

0 comments on commit 609f854

Please sign in to comment.