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.
<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="mytestapplication" android:host="*"/> </intent-filter>
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