Android – test android deep link urls through adb to launch the app


When I type the command in adb:

./adb shell am start -W -a android.intent.action.VIEW -d "example:gizmos" com.myapp

I get this error:

Starting: Intent { act=android.intent.action.VIEW dat=example://gizmos pkg=com.myapp }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=example://gizmos flg=0x10000000 pkg=com.myapp }

But when I type the command in adb:

./adb shell am start -W -a android.intent.action.VIEW -d "example:gizmos" com.myapp.activity.DeepLinkActivity

Everything works fine and I get the message and I can see the activity launch on the phone:

Starting: Intent { act=android.intent.action.VIEW dat=example://gizmos cmp=com.myapp.activity.DeepLinkActivity }
Status: timeout
Activity: com.myapp.activity.DrawerActivity

My question is why do I need to get full path of my activity and not just package name? Because when the external apps or browser will try to deep link they will not invoke the activity in my app.

This is my AndroidManifest.xml

            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="example"
                  android:host="gizmos" />


Best Answer

You don't need to specify full path to your activity, but if you want to test whether you react properly to URI in your app just specify app package:

adb shell am start -a android.intent.action.VIEW -d "example://gizmos" com.myapp

Also there is bug in command you provided - there should be example://gizmos not example:gizmos