Android深度链接具有多个查询参数

Var*_*ani 44 android deep-linking adb

我正在尝试深层链接我的应用程序,并在我的AndroidManifest.xml中实现了以下内容以打开正确的活动.

<activity
    android:name=".ui.activities.MyActivity"
    android:label="@string/title_activity"
    android:screenOrientation="portrait">
    <!-- ATTENTION: This intent was auto-generated. Follow instructions at
    https://g.co/AppIndexing/AndroidStudio to publish your Android app deep links. -->
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- ATTENTION: This data URL was auto-generated. We recommend that you use the HTTP scheme.
        TODO: Change the host or pathPrefix as necessary. -->
        <data
            android:host="myHost"
            android:scheme="myCustomScheme" />
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

我正在使用adb测试活动

adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id&value=92&title=test" com.myApp.android
Run Code Online (Sandbox Code Playgroud)

Activity正在打开,但只传递给intent中活动的URI

myCustomScheme://myHost?key=category_parent_id
Run Code Online (Sandbox Code Playgroud)

它在"&"后跳过一切

我确实在SO上查找但没有找到任何有多个查询参数的东西.

任何帮助,将不胜感激.:)

Khi*_*yat 104

请在使用adb进行测试时添加\ before&sign

复制这个

\

  • 为我工作.有谁知道你为什么要这样做? (2认同)

Sim*_*uis 16

您可以使用简单的引号包装shell命令(以避免修改uri内容):

adb shell 'am start -d "myCustomScheme://myHost?key=category_parent_id&value=92&title=test"'
Run Code Online (Sandbox Code Playgroud)

  • 这应该是公认的答案,因为它不需要更改 URI 或执行任何编码 (3认同)