gpt4 book ai didi

android - 如何在 Android 8 中链接 html 页面

转载 作者:行者123 更新时间:2023-11-29 23:30:52 24 4
gpt4 key购买 nike

我有一些在线帮助,其中包含几个相互链接的 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:

该页面仅包含一个简单的布局和一个几乎为空的 Activity :

<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

最佳答案

您可以尝试覆盖 shouldOverrideUrlLoading 方法,more info .

Give the host application a chance to take control when a URL is about to be loaded in the current WebView. If a WebViewClient is not provided, by default WebView will ask Activity Manager to choose the proper handler for the URL. If a WebViewClient is provided, returning true causes the current WebView to abort loading the URL, while returning false causes the WebView to continue loading the URL as usual.

例如,您可以尝试简单地从他那里返回 false:

  WebViewClient client = new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
};

关于android - 如何在 Android 8 中链接 html 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52697166/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com