移除全局异常捕获后杀死进程
This commit is contained in:
parent
a50a7140fd
commit
60da453114
@ -278,17 +278,17 @@ public class AppContext extends CommonAppContext {
|
|||||||
Log.e("ApplicationError", "主线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
|
Log.e("ApplicationError", "主线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
//闪退后finish所有Activity并且杀死进程
|
//闪退后finish所有Activity并且杀死进程
|
||||||
for (WeakReference<Activity> activity : activities) {
|
/* for (WeakReference<Activity> activity : activities) {
|
||||||
if (activity != null && activity.get() != null) {
|
if (activity != null && activity.get() != null) {
|
||||||
activity.get().finish();
|
activity.get().finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Process.killProcess(Process.myPid());
|
*//* Process.killProcess(Process.myPid());
|
||||||
System.exit(0);*/
|
System.exit(0);*//*
|
||||||
setFirebaseCrashData();
|
setFirebaseCrashData();
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}, 100);
|
}, 100);*/
|
||||||
})
|
})
|
||||||
.setUncaughtCrashHandler((t, e) -> {
|
.setUncaughtCrashHandler((t, e) -> {
|
||||||
Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
|
Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
|
||||||
|
@ -101,10 +101,9 @@ public class NeverCrashUtils {
|
|||||||
Log.e(TAG, "未捕获的主线程异常行为", e);
|
Log.e(TAG, "未捕获的主线程异常行为", e);
|
||||||
}
|
}
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Toast.makeText(application, "发生闪退", Toast.LENGTH_SHORT).show();
|
Toast.makeText(application, "发生闪退:"+e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()), throwableToString(e), "error.log");
|
FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()), throwableToString(e), "error.log");
|
||||||
getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e);
|
getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -368,34 +368,10 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
|
|||||||
.setOnBannerClickListener(new OnBannerClickListener() {
|
.setOnBannerClickListener(new OnBannerClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onBannerClick(List datas, int p) {
|
public void onBannerClick(List datas, int p) {
|
||||||
if (true) {
|
if (false) {
|
||||||
/* System.err.println("cache = " + mContext.getCacheDir().getAbsolutePath());
|
throw new NullPointerException("空指针测试异常");
|
||||||
String type = "image/*";
|
// mContext.startActivity(new Intent(mContext, TestActivity.class));
|
||||||
String filename = "/ztest/myPhoto.jpg";
|
//return;
|
||||||
String mediaPath = Environment.getExternalStorageDirectory() + filename;
|
|
||||||
// Create the new Intent using the 'Send' action.
|
|
||||||
Intent share = new Intent(Intent.ACTION_SEND);
|
|
||||||
|
|
||||||
// Set the MIME type
|
|
||||||
share.setType(type);
|
|
||||||
|
|
||||||
// Create the URI from the media
|
|
||||||
File media = new File(mediaPath);
|
|
||||||
Uri uri = FileProvider.getUriForFile(mContext,
|
|
||||||
mContext.getPackageName() + ".fileprovider",
|
|
||||||
media
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add the URI to the Intent.
|
|
||||||
share.putExtra(Intent.EXTRA_STREAM, uri);
|
|
||||||
share.putExtra(Intent.EXTRA_TEXT, "test");
|
|
||||||
// Broadcast the Intent.
|
|
||||||
// share.setPackage("com.whatsapp"); //WhatsApp
|
|
||||||
|
|
||||||
// share = new Intent(Intent.ACTION_VIEW, Uri.parse("https://line.me/R/share?text=test")); //Line
|
|
||||||
mContext.startActivity(Intent.createChooser(share, "Share to"));*/
|
|
||||||
mContext.startActivity(new Intent(mContext, TestActivity.class));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (mBannerList != null) {
|
if (mBannerList != null) {
|
||||||
if (p >= 0 && p < mBannerList.size()) {
|
if (p >= 0 && p < mBannerList.size()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user