【问题标题】:Why android deep linking makes my link on Whatsapp opened inside Whatsapp's App?为什么 android 深度链接使我在 Whatsapp 上的链接在 Whatsapp 的应用程序中打开?
【发布时间】:2018-10-24 02:37:12
【问题描述】:

我正在逐步关注this tutorial,以便在 Android 上进行深度链接。部分代码如下,基本上会在我的App的webview中打开url。

Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
if (data != null) {
    String path = data.getPath();
    String query = data.getEncodedQuery();
    String hash = data.getEncodedFragment();

    String fullPath = path;
    if(query !=  null){
        fullPath = path + "?" + query;
        if(hash != null){
            fullPath = path + "#" + hash;
        }
    }

    String openUrl = "https://" + Config.domain + fullPath;

    ....
    // and open in webview

}

它几乎可以完美运行。 Chrome 浏览器上的链接可以在我的应用程序中打开。但是,当点击 Whatsapp 等消息应用程序上的链接时,该链接会在 Whatsapp 本身上打开,方法是替换 Whatsapp 上的原始内容!除非我退出应用程序并再次打开它,否则我无法返回到 Whatsapp 的正常消息屏幕!

为什么会出现这样的行为,我该怎么做才能解决它?谢谢!

【问题讨论】:

    标签: android android-studio webview android-webview deep-linking


    【解决方案1】:

    我遇到了完全相同的问题,这是因为我将“launchMode”设置为 singleTop。我将其更改为 singleTask 并且效果很好。

    【讨论】:

    • 太棒了!!经过大量搜索,终于找到了它的工作。
    猜你喜欢
    • 1970-01-01
    • 2021-11-08
    • 2018-07-04
    • 2021-10-08
    • 1970-01-01
    • 2020-04-05
    • 2017-08-07
    • 2021-12-20
    • 1970-01-01
    相关资源
    最近更新 更多