While working on a PhoneGap application , there was an requirement to take photo using device camera and upload in the sever. And PhoneGap provides an easy way to interact with the device camera and take photo using Camera API.
Description: Basically there are two ways to take photo from mobile device.
1. Taking photos using Camera
2. Taking photos from Library/Gallery
So here we will focus on displaying the image in our application using both ways. PhoneGap provides the camera.getPicture method which can help us to invoke camera and take images from mobile devices.
Custom URL scheme is the mechanism through which third party applications can interact with each other. Suppose we want an interaction between our app and the default email application in the device. Apps that support custom URL schemes can use the schemes to communicate with other applications and also initiate specific tasks. For example, an app can open from default email app in IOS devices using custom URL.
Description: To communicate with an app using a custom URL, we need to register the custom URL scheme in our appname-info.plist file. Apple by default supports for the http, mailto, tel, and SMS URL schemes. So if our URL scheme matches with the scheme mentioned by Apple then the Apple provided application will launch instead of our application. Therefore we need to be very careful before declaring the scheme.
When we are launching the Android application using custom URL scheme, we may need to extract the parameter attached with the custom URL that we are using as link in the other native application like email.
In my last post I have described how to launch the android application using custom scheme. So continuing with that here we can get to know how to use the same URL scheme along with WebIntent Plugin to get the parameter attached with the custom URL.
After creating the intent in the manifest file in the next step we need to pass the parameter via the href in the anchor tag. Lets say we are passing the user name as parameter in the href along with the custom scheme and we need the same user name after launching the application.
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.