Android 意图过滤器删除查询字符串

Android intent filter drops query string

我在 AndroidManifest.xmlintent-filter 节点中定义了一个数据标签,如下所示:

<data
    android:scheme="http"
    android:host="example.com"
    android:pathPrefix="/path/pageEnum" />

我要捕获的路径是 http://example.com/path/pageEnum?one=1&two=2&three=3

我正在从 adb 启动意图,如下所示:

adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://example.com/path/pageEnum?one=1&two=2&three=3"

目标 activity 成功启动,但是当我在 onCreate() 中调用 getIntent().getDataString() 时,字符串值为 http://example.com/path/pageEnum?one=1

除了第一个参数之外的所有查询参数都被删除。

是否有任何解决方法来确保我获得所有查询参数?

google's documentation 中没有关于此行为的内容。

您应该用单引号将 adb shell 命令括起来:

adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://example.com/path/pageEnum?one=1&two=2&three=3"'