我有一个小的在线帮助,包括几个HTML相互链接。
这在过去很好,但是在Android 8中,只能显示条目页面,只要单击任何链接,我就会得到:
10-08 09:04:17.616 22871 22871 E AndroidRuntime: FATAL EXCEPTION: main
10-08 09:04:17.616 22871 22871 E AndroidRuntime: Process: net.sourceforge.uiq3.fx602p, PID: 22871
10-08 09:04:17.616 22871 22871 E AndroidRuntime: android.os.FileUriExposedException: file:///android_asset/Modes.html exposed beyond app through Intent.getData()
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.os.StrictMode.onFileUriExposed(StrictMode.java:1958)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.net.Uri.checkFileUriExposed(Uri.java:2356)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.content.Intent.prepareToLeaveProcess(Intent.java:10511)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.content.Intent.prepareToLeaveProcess(Intent.java:10465)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1616)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.app.Activity.startActivityForResult(Activity.java:4564)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.app.Activity.startActivityForResult(Activity.java:4522)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:784)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.app.Activity.startActivity(Activity.java:4883)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.app.Activity.startActivity(Activity.java:4851)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.content.ContextWrapper.startActivity(ContextWrapper.java:377)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at aiM.startActivity(SourceFile:22)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at agA.a(SourceFile:34)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(SourceFile:173)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.os.MessageQueue.nativePollOnce(Native Method)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.os.MessageQueue.next(MessageQueue.java:325)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.os.Looper.loop(Looper.java:142)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6944)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
10-08 09:04:17.616 22871 22871 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)当然,所有的页面都显示在应用程序中,没有什么是“泄露”到外部的。即使:这只是网上的帮助,如果是的话,我也不在乎。
够了:怎么解决这个问题?
更新1:
该页面只包含一个简单的布局和几乎为空的活动:
<LinearLayout
android:layout_height='match_parent'
android:layout_width='match_parent'
xmlns:android='http://schemas.android.com/apk/res/android'
>
<WebView
android:id='@+id/Help'
android:layout_height='match_parent'
android:layout_width='match_parent'
></WebView>
</LinearLayout>@igor_rb建议让shouldOverrideUrlLoading过载WebViewClient --但我现在并不真正使用WebViewClient。
发布于 2018-10-08 07:23:50
您可以尝试重写shouldOverrideUrlLoading方法,更多信息。
当URL即将加载到当前WebView中时,给主机应用程序一个控制的机会。如果没有提供WebViewClient,默认情况下,WebView将要求Activity为该URL选择合适的处理程序。如果提供了一个WebViewClient,返回true将导致当前WebView中止加载该URL,而返回false则会导致WebView一如既往地继续加载URL。
例如,您可以尝试简单地从他返回false:
WebViewClient client = new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
};https://stackoverflow.com/questions/52697166
复制相似问题