Url Scheme 意图不适用于获取参数

Jej*_*cgb 1 android url-scheme intentfilter android-intent chrome-custom-tabs

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

在我的应用程序中,我有以下意图过滤器:

<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>
Run Code Online (Sandbox Code Playgroud)

但是,意图有时不起作用。似乎每次在 URL 中使用字符“&”时,都不会触发意图。我得到一个 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"

NOK 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"

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

正常吗?我知道应该将此类意图与 REST 参数一起使用。然而,当调用带有 get 参数的 URL 时,不会触发意图似乎很奇怪。

Jej*_*cgb 5

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

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