94

I'm trying to deep link my app and have implemented the following in my AndroidManifest.xml to open the proper activity.

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

And I'm testing the activity from adb using

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

The Activity is opening but the URI which is passed to the activity in the intent is only

myCustomScheme://myHost?key=category_parent_id

Its skipping everything after '&'

I did look up here on SO but didn't find anything with multiple query parameters.

4 Answers 4

240

Just add \ before & sign when testing with adb.

Copy this:

adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id\&value=92\&title=test" com.myApp.android

9
  • 4
    Worked for me. Does anyone know why do you need to do this? Jul 5, 2016 at 22:11
  • Also, if the title field has white-spaces then prefix them too with backslashes.
    – Gagan
    Nov 12, 2017 at 17:05
  • I was missing the \ before the &. Thanks, dude! Feb 5, 2019 at 18:37
  • When I have the query parameter in the URL, Android system not not showing my app in suggestions but without query params it's working. Please what couldhelp be the issue. URL: "myCustomScheme://myHost?key=xxx"
    – user448250
    May 3, 2019 at 3:28
  • 2
    I use %26 instead of & and It works in adb and browser
    – Shojaeddin
    Aug 17, 2022 at 8:16
58

You can wrap the shell command with simple quotes (to avoid modifying the uri content):

adb shell 'am start -d "myCustomScheme://myHost?key=category_parent_id&value=92&title=test"'
2
  • 3
    This is should be the accepted answer since it doesn't require changing the URI or doing any encoding
    – Paul T.
    Dec 11, 2019 at 23:30
  • what about link in email?
    – user924
    Jul 29, 2021 at 7:03
4

For osx / mac users with android studio

Load adb

export PATH="/Users/your_user/Library/Android/sdk/platform-tools":$PATH

Check that the app is recognized

adb shell am start -n com.package/.activities_package_name.MainActivity

Test deeplink

adb shell 'am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id\&value=92\&title=test" com.myApp.android'

Don't forget the ' '

1
  • from email it also skips
    – user924
    Jul 29, 2021 at 7:02
2

Just encode your url parameters and it will work. It might be google's parsing bug.

Before:

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

After:

adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key%3Dcategory_parent_id%26value%3D92%26title%3Dtest" com.myApp.android

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.