I followed the insttructions on https://developer.android.com/training/app-indexing/deep-linking.html, but when I want to trigger the intent through adb
with:
Make sure your URL is in this format (with the cap letters replaced by your own):
android-app://COM.YOUR.APP.IDENTIFIER/SCHEME/HOST?somegetparams
The adb tool does not require this format. With the above you can now put it in an src, or an href, like so:
<iframe src="android-app://COM.YOUR.APP.IDENTIFIER/SCHEME/HOST?somegetparams"> </iframe>
<a href="android-app://COM.YOUR.APP.IDENTIFIER/SCHEME/HOST?somegetparams">LINK</a>
Use this intent filter instead,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://gizmos” -->
<data
android:host="gizmos"
android:scheme="example" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data
android:host="www.example.com"
android:pathPrefix="gizmos"
android:scheme="http" />
</intent-filter>
In my case, I am using an emulator and not an actual usb connected device, and hence I had to change -d to -e, like so :
adb shell am start -W -a android.intent.action.VIEW -e "http://www.example.com" com.example
Note the -e before the deep link.
./adb shell am start -n packagename/.splash.SplashActivity -d "schemeName://content"
In my case, I was putting deep linking intent filter in MainActivity which is also main launcher. That caused the problem.
After I created another separate activity and put intent filter there, it solved the problem. Hope this can help others who are facing the same issue.
After some tests this is what worked for me:
<activity android:name=".activities.MainActivity">
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix=""
/>
<data android:scheme="myschema"
android:host="example"
android:pathPrefix=""
/>
</intent-filter>
</activity>
This works when clicking any link in the browser such as "http://www.example.com", "http://www.example.com/" or "http://www.example.com/whatever". The same with "myschema://example/whatever".
Also works with adb
using this command (with any of those URLs):
adb shell am start -W -a android.intent.action.VIEW -d "http://www.example.com" com.example
Hope it helps to get you started.
When everything is working you will probably want to configure a different pathPrefix
for different activities.