Launching PhoneGap Android Application Using Custom URL Scheme

Sometimes we need to open our Android application from other native application like email, map, default browser etc. It is quite possible using PhoneGap and also easy to implement. Here we can use custom URL scheme to fulfill our requirement.

Suppose we need to open the Android PhoneGap application from other application like email. So we need to create an intent which will manage the custom schema and help to launch the application. We can create the intent in the AndroidManifest.xml file.
Below is the example to create the intent in manifest file.

<action android:name="android.intent.action.VIEW" />
<category     android:name="android.intent.category.DEFAULT" />
<category   android:name="android.intent.category.BROWSABLE" />
<data android:scheme="mytestapplication"   android:host="*"/>

We have declared the custom schema as “mytestapplication” in the intent. So when we use the same scheme from other application, then the intent will detect the scheme and launch the application automatically.

Now we just need to create the custom URL to launch the application like this.

<a href="mytestapplication://open from custom url">Launch Application</a>

So when we click the link in default email application in Android devices, It will open our application automatically by detecting the scheme. Here we can see the href starts with “mytestapplication” and we have mentioned the same scheme in intent in the manifest file.

By using the above example we can launch the Android PhoneGap application using custom URL scheme

Written By: Sourabha Kumar Sahoo, Software Developer, Mindfire Solutions

3 thoughts on “Launching PhoneGap Android Application Using Custom URL Scheme

  1. When I launching my phone gap from URL using this method it crashes right away with message Unfortunately, MyApp has stopped. Its working fine, if I open app from icon. Any idea?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s