报错信息如下
2022-10-25 14:16:17.810 3200-3200/com.test.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.android, PID: 3200
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.test.android/files/Documents//user/page_detail.html?message=%E5%BA%95%E9%83%A8%E5%8F%8D%E8%BD%AC&color=red&qsid=999&_isB=0&_open_app=1&_mob_system=android&_iphoneX=false&_bar_height=20&wdbk= exposed beyond app through Intent.getData()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:2083)
at android.net.Uri.checkFileUriExposed(Uri.java:2404)
at android.content.Intent.prepareToLeaveProcess(Intent.java:11167)
at android.content.Intent.prepareToLeaveProcess(Intent.java:11120)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1732)
at android.app.Activity.startActivityForResult(Activity.java:5412)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
at android.app.Activity.startActivityForResult(Activity.java:5337)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
at android.app.Activity.startActivity(Activity.java:5819)
at android.app.Activity.startActivity(Activity.java:5787)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:383)
at Wb.startActivity(HwWebview-11.1.5.315.3337:3)
at b5.shouldIgnoreNavigation(HwWebview-11.1.5.315.3337:28)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(HwWebview-11.1.5.315.3337:1)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:363)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
全是系统报错,看的一脸懵,完全不知道哪来的参数startActivity,最后发现WebView的setWebViewClient 里的shouldOverrideUrlLoading触发回调,重写方法return false 不再崩溃
webview.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
网友评论