首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在android中使用深度链接来打开应用程序和获取参数?

如何在android中使用深度链接来打开应用程序和获取参数?
EN

Stack Overflow用户
提问于 2019-01-21 22:56:04
回答 1查看 1.6K关注 0票数 1

所以我尝试在我的应用程序中做一个deep-linking来确认用户输入的电子邮件。到目前为止,我还不能打开我的应用程序抛出后端给我的链接。

到目前为止我已经做了这件事。

,这是我的manifest.xml

代码语言:javascript
复制
 <activity
            android:name=".ui.registration.activities.ARegistration"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize">

            <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="https"
                    android:host="something.com"
                    android:path="/verify-email" />

            </intent-filter>
        </activity>

这是我电子邮件的网址

https://something.com/verify-email?registrationId=1111&token=12345

这是我的注册活动

代码语言:javascript
复制
override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.a_registration)
        colorStatusBar(frameRegistration, R.color.colorPrimary)

        val data = intent?.data

        val token = data?.getQueryParameter("token") //trying to obtain the token here
        Toast.makeText(applicationContext,token,Toast.LENGTH_SHORT).show()

}

有人能帮忙吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-22 00:24:34

代码语言:javascript
复制
<data
    android:host="something.com"
    android:pathPattern="/verify-email"
    android:scheme="https" />

粘贴这个,你就没事了。

或者,如果这不起作用,那么转到:将->应用程序设置为->,将应用程序->设置为默认设置。并将“转到受支持的URL”更改为始终询问或在此应用程序中。可能您选择浏览器作为您的应用程序打开url链接的默认值。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54298893

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档