【问题标题】:Android intent filter drops query stringAndroid 意图过滤器丢弃查询字符串
【发布时间】:2017-07-28 08:36:04
【问题描述】:

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

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

我要捕获的路径是http://example.com/path/pageEnum?one=1&amp;two=2&amp;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&amp;two=2&amp;three=3"

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

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

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

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

【问题讨论】:

  • 您的&amp; 片段可能正在被您运行adb shell 命令的shell 吃掉。与其使用adb shell,不如编写一个应用程序调用startActivity(),并使用所需的Intent。
  • 这就是问题所在,谢谢!
  • 用单引号包裹你的 adb shell 命令:adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://example.com/path/pageEnum?one=1&amp;two=2&amp;three=3"'
  • @SimonMarquis 你的回答有效!谢谢。应该作为答案发布。

标签: android android-intent deep-linking


【解决方案1】:

你应该用单引号包裹你的 adb shell 命令:

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

【讨论】:

    猜你喜欢
    • 2011-04-21
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 2012-09-11
    • 2016-07-16
    • 1970-01-01
    • 2015-05-14
    相关资源
    最近更新 更多