26

I'm working on app that requires Custom URL Scheme looks like "appname://"

I've searched lot of things and also found many related questions, but I'm still having trouble.

How I can test this URL Scheme from a browser? Currently, whenever I type in a browser's address bar "appname://", it goest directly to a Google search.

I have this in my AndroidManifest.xml:

<intent-filter> 
         <action android:name="android.intent.action.VIEW" /> 
         <category android:name="android.intent.category.DEFAULT" /> 
         <category android:name="android.intent.category.BROWSABLE" /> 
         <data android:scheme="appname"
             android:host="appnamehost"/>
</intent-filter>
0

1 Answer 1

54

That is easy via adb. Check this command:

adb shell am start -a android.intent.action.VIEW -d "appname://appnamehost" your.package.name

However you should use your package name as schema. So you can be absolutely sure that there is no conflict (or in detail a intent chooser).

If you have multiple devices you need to execute adb devices. This will result a output like this:

List of devices attached
1645e1d0b86b    device
S9WM00904386    device

Then you can use that id from above to address a concrete device with the -s parameter. This will result a command line like this:

adb -s S9WM00904386 shell [...]

In case of a browser link this is also easy. You just need to add this line of html:

<a href="appname://appnamehost">Click me</a>

If you want a fallback in your url you could try the intent url:

<a href="intent://apphostname#Intent;scheme=appname;package=your.package.name;S.browser_fallback_url=http%3A%2F%2Fwww.example.com;end">with alternative</a>

This will open your app even if you schema is not unique, and if you app is not installed it will open example.com.

6
  • Thanks for answer Rekine, I really appreciate it...I know how to test it by command line and I did this already and working fine, I need to know if I can directly test it from browser, Also you are right about custom scheme name, I just provided example here, real scheme is my bundle id :) , Let me know if you know how to test it directly on browser. Aug 7, 2015 at 12:09
  • even, by command line, it works for jelly bean but not working for lolipop Aug 7, 2015 at 12:11
  • where I can add this href line ? it would be better if you can post some code snippet here. Aug 7, 2015 at 12:38
  • 5
    Thank you Rekire, By making html from jsfiddle and run on mobile brower, it's working fine. :) Aug 8, 2015 at 6:21
  • Can I get the link to JSfiddle ? I'm not seeing it in the comments.
    – Vasanth
    Jun 19, 2020 at 13:38

Your Answer

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

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