【问题标题】:Can't get Uri Data from Deep Link无法从 Deep Link 获取 Uri 数据
【发布时间】:2015-12-30 14:03:32
【问题描述】:

我想从浏览器重定向到我的应用程序,因此我在 Manifest 中为我的 Activity 使用以下代码:

<intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="fivos"
                android:host="book"
                />
        </intent-filter>

// 接受以“fivos://book”开头的 URI

浏览器发送的 Uri 中还有一些参数(例如 fivos://book?username=george)。 在我被重定向到的 Activity 中,我使用以下代码获取 Uri 但参数似乎不存在于 Uridata 对象中,除了方案和主机

Uri URIdata = getIntent().getData();        
if(URIdata != null){
        String scheme = URIdata.getScheme();
        String host = URIdata.getHost();
        List params = URIdata.getPathSegments();
        String username = params.get(0).toString();
    }

我的清单中是否缺少某些内容?

【问题讨论】:

    标签: android parameters uri intentfilter deep-linking


    【解决方案1】:

    我使用以下代码获取Uri,但是Uridata对象中似乎不存在参数,除了sheme和主机

    URL 中?Uri 后面的内容是查询参数,您可以通过like getQuery() 方法从Uri 检索。

    【讨论】:

    • 我清除了浏览器的数据并重复了该过程。 Uridata 对象现在与浏览器发送的一样,包含参数。 @CommonsWare 感谢您的即时答复!
    猜你喜欢
    • 2022-10-21
    • 1970-01-01
    • 2018-04-16
    • 1970-01-01
    • 2022-11-27
    • 2020-12-24
    • 2019-12-05
    • 2022-08-19
    • 1970-01-01
    相关资源
    最近更新 更多