android - Url Scheme Intent 不适用于获取参数

标签 android android-intent intentfilter url-scheme chrome-custom-tabs

我目前正在开发基于 OpenId Connect 和 Chrome CustomTabs 的身份验证应用。在身份验证流程中,用户被发送到重定向 URL,我在这里遇到了一些问题。

在我的应用程序中,我有以下 intent-filter :

<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="sncfapp" android:host="callbackrurl" />
</intent-filter>

但是, Intent 有时不起作用。似乎每次在 URL 中使用字符“&”时,都不会触发 Intent 。我得到一个 ERR_UNKNOWN_URL_SCHEME。

我尝试通过 adb(也使用另一个接收器)启动一些 URL,这是我的结果:

确定 adb shell am start -a android.intent.action.VIEW -d "fitbittester://logincallback"

确定 adb shell am start -a android.intent.action.VIEW -d "sncfapp://callbackrurl"

确定 adb shell am start -a android.intent.action.VIEW -d “sncfapp://callbackrurl?code=45644546”

不成功 adb shell am start -a android.intent.action.VIEW -d "sncfapp://callbackrurl?code=45644546&scope=test%20"

确定 adb shell am start -a android.intent.action.VIEW -d "sncfapp://callbackrurl?scope=test%20"

确定 adb shell am start -a android.intent.action.VIEW -d "fitbittester://logincallback?scope=test%20"

不成功 adb shell am start -a android.intent.action.VIEW -d "fitbittester://logincallback?scope=test%20& code=1144"

这正常吗?我知道这样的 Intent 应该与 REST 参数一起使用。然而,调用带有 get 参数的 URL 时未触发 Intent 似乎很奇怪。

最佳答案

这是我找到的解决方案:我必须使用转义字符“\”才能在 ADB 中使用 & 字符。

$ adb shell am start "http://www.example.com?param1=1\&param2=2"

关于android - Url Scheme Intent 不适用于获取参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34609329/

相关文章:

android - App Links 的多子域支持

用于聊天应用程序的 Android 数据库加载聊天

java - 访问 TextView 时出现 NullPointerException

android - Android Activity 中未调用 OnActivityResult()

安卓 : Create a single task with multiple applications' activities (Lauchmode issue)

android - 注册一个应用程序以在 SEND 操作中接收所有文件类型

java - 操作栏作为 fragment

android - 如何更改谷歌地图 v2 android 中的信息窗口(自定义)位置?

android - 打开 Gmail 消息 Intent

android浏览具有定义扩展名的文件 Intent