From 60da4531143c45bb6a80d66a686211bb0ed67aaf Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 13 Feb 2023 16:05:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=85=A8=E5=B1=80=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8D=95=E8=8E=B7=E5=90=8E=E6=9D=80=E6=AD=BB=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/shayu/phonelive/AppContext.java | 8 ++--- .../com/shayu/phonelive/NeverCrashUtils.java | 3 +- .../main/views/MainHomeLiveViewHolder.java | 32 +++---------------- 3 files changed, 9 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index 4cc9e4c31..af69b040a 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -278,17 +278,17 @@ public class AppContext extends CommonAppContext { Log.e("ApplicationError", "主线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息 e.printStackTrace(); //闪退后finish所有Activity并且杀死进程 - for (WeakReference activity : activities) { + /* for (WeakReference activity : activities) { if (activity != null && activity.get() != null) { activity.get().finish(); } } - /* Process.killProcess(Process.myPid()); - System.exit(0);*/ + *//* Process.killProcess(Process.myPid()); + System.exit(0);*//* setFirebaseCrashData(); new Handler(Looper.getMainLooper()).postDelayed(() -> { throw new RuntimeException(e); - }, 100); + }, 100);*/ }) .setUncaughtCrashHandler((t, e) -> { Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息 diff --git a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java index f99f3a492..93f23b13b 100644 --- a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java +++ b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java @@ -101,10 +101,9 @@ public class NeverCrashUtils { Log.e(TAG, "未捕获的主线程异常行为", e); } 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"); getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e); - return; } } }); diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java index 4b8688cb1..b1659c847 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java @@ -368,34 +368,10 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement .setOnBannerClickListener(new OnBannerClickListener() { @Override public void onBannerClick(List datas, int p) { - if (true) { - /* System.err.println("cache = " + mContext.getCacheDir().getAbsolutePath()); - String type = "image/*"; - String filename = "/ztest/myPhoto.jpg"; - 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 (false) { + throw new NullPointerException("空指针测试异常"); + // mContext.startActivity(new Intent(mContext, TestActivity.class)); + //return; } if (mBannerList != null) { if (p >= 0 && p < mBannerList.size()) {