If you are developing a PhoneGap app and need to use a URL scheme then you might have realized that Android doesn’t have an easy solution like iOS. After banging my head for days I have finally come up with a simple solution.
To get started you have to modify your AndroidManifest.xml file. Add the following intent-filter to the manifest file:
<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=”APP_SCHEME”/> </intent-filter>
Make sure you replace the “APP_SCHEME” with the url scheme you want to use, for example if you want to use the url myapp:// as your scheme then you would change “APP_SCHEME” to “myapp”.
Next go to your main Java file were the super.loadUrl(“file:///android_asset/www/index.html”); line is located. And make sure to add
to the top of the file. Next add the following lines after the super.loadUrl(“file:///android_asset/www/index.html”); line.
Now you are done! This will behave similar to the handleOpenURL function on iOS.