所以我试图在我的应用程序中做一个深层链接
来确认用户输入的电子邮件。到目前为止,我无法打开我的应用程序抛出后端给我的链接。
到目前为止我已经做到了。
这是我的 manifest.xml
<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>
这是我电子邮件中的 URL
https://something.com/verify-email?registrationId=1111&token=12345
这是我的注册 Activity
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()
}
有人可以帮忙吗?
最佳答案
<data
android:host="something.com"
android:pathPattern="/verify-email"
android:scheme="https" />
粘贴这个就可以了。
或者 如果这不起作用,请转到:设置 -> 应用程序 -> 您的应用程序 -> 设置为默认值。并将“转到支持的 URL”更改为始终询问或在此应用程序中。可能是您选择浏览器作为您的应用打开 url 链接的默认浏览器
关于android - 如何在 android 中使用深层链接打开应用程序并获取参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54298893/