我目前正在开发基于 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\¶m2=2"
关于android - Url Scheme Intent 不适用于获取参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34609329/