有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何处理webview应用程序的应用程序链接

我正在尝试处理webview应用程序中的应用程序链接。 这意味着,如果用户单击类似example.com/example.html的链接,应用程序将显示open with对话框。 我已经实现了这一点:

    <intent-filter>
        <action 安卓:name="安卓.intent.action.VIEW" />
        <category 安卓:name="安卓.intent.category.DEFAULT" />
        <category 安卓:name="安卓.intent.category.BROWSABLE" />
        <data 安卓:scheme="http" />
        <data 安卓:host="www.example.com" />
    </intent-filter>

还有我的主要活动。java包含以下代码:

public boolean shouldOverrideUrlLoading(WebView view, String url) {

                ...
                ...

                if (Uri.parse(url).getHost().contains("www.example.com")) {
                    return false;
                }

                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                view.getContext().startActivity(intent);
                return true;

            }

        });

但问题是,当用户使用应用程序打开链接时,它会显示主屏幕,而不是单击的链接/页面

我如何实现这一点

谢谢


共 (0) 个答案