Android: Handle Custom protocol Urls

13May

You might ever found custom protocol urls like below:

example://SomeHostPrefix/?UserName=abcdef&SessionId=12345

When you copy this custom protocol url in your mobile browser, you will find that an Android App is activated, rather than a new web page. How to implement such functions in your own Android App? This article offers a walk through example to do so.

Create an Android App in Android Studio, with an empty activity called MainActivity. In order to make the Android App handle the given custom url, in the AndroidManifest.xml, add below code:

Note that we added a new <intent-filter> and a new <data> node in the above code, where you can specify the custom protocol scheme and the host, as highlighted above.