Customizing Build-in Binding in KnockoutJs using PhoneGap

Introduction:
Knockout.Js not only gives us the ability to use build-in bindings but also allows us to use our own custom bindings. In this blog, we will basically look into creating the custom bindings for Knockout.Js using PhoneGap.

Description:
Creating custom binding is much easier than ever. Before moving forward, we need to get into the basic structure to register our custom binding. To register a custom binding, we need to add it as a sub-property to ko.bindingHandlers. Continue reading

Conversion of speech to text in Android devices using PhoneGap

Introduction:
Speech to text conversion is the mechanism to translate the spoken words into text. It is also known as automatic speech recognition. Whereas Android provides the native functionality to recognize the speech and convert the same to text. We just need to invoke the native module to fulfill our task.

Description:
While working with voice to text conversion in Android using PhoneGap I came across SpeechRecognizer plugin.It is very easy to integrate in PhoneGap application and also helps us to recognize the speech and convert the same to text in json array. So bellow are the steps to integrate this plugin with Android using PhoneGap. Continue reading

How to add/use plugins in Phonegap 3.0

Introduction:
Phonegap 3.0 plugins can be added to the project using the CLI (Command Line Interface). Phonegap 3.0 had made the developers life much easier to utilize the plugins. We just need to follow two basic steps to use the plugins.

Description:
Here are the two basic steps we need to flow.
1. Adding the plugin to application
2. Implementing the javascript function

Before moving forward, I would like to elaborate the basic structure used with Phonegap 3.0 plugins. The plugins will be having the below structure. Continue reading

Getting geo-coordinates from address in PhoneGap application using Google API

Introduction:
In this post we will discover the use of Google API to get the latitude and longitude by passing the address/location in PhoneGap application.

Description:
It is very easy to get the geographic coordinates (latitude & longitude) from a particular address using Google API. Google API exposes Geocoder() method which takes the address as input parameter and returns the geometry.location as output. We can parse the geometry.location to get the latitude and longitude value.

Here is the code snippets to get the latitude and longitude value from specific address. Continue reading

Simple steps to create phonegap 3.0 plugin for Android

Introduction:
Phonegap plugins allows us to customize the way to use the native features as per our need. Basically, the communication between JavaScript and native code is accomplished by the bridge provided by Phonegap.
Starting with the Android platform, to develop plugin, it follows some basic flow. We need to call cordova.exec() function in JavaScript, which will be mapped with our execute() method defined in our native java file. We can also pass useful parameters and can also define the success and error callback methods to trace the flow.

Description:
Here are three basic steps we need to flow to create the plugin.
1. Creating the Native Java Interface
2. Creating the JavaScript Interface
3. Configuring the plugin Continue reading

Getting address from latitude/longitude value using Google API and PhoneGap

Introduction:
In this post we will discover the use of Google API to get the current address and type of address by using the PhoneGap geolocation API and Google API.

Description:
Sometimes we need to get the address of a location from geolocation value. It is very very easy to get the same using Google API and PhoneGap. First we need to get the geolocation value i.e latitude and longitude using PhoneGap geolocation API.

Here are the steps that we need to follow.

1. Include the Phonegap/Cordova JavaScript file and Google API JavaScript file inside your html page.

<script type="text/javascript" src="phonegap/cordova.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"></script>

Continue reading

Few issues and solutions in iOS7 using Phonegap 2.6

Issue #1 : Status bar issue in ios7 using phonegap:

In Phonegap by default the apps are not with full screen.

But in iOS7, all the applications are running full screen so the status bar is overlapping with the top part of the webview/page.

Fix
Open MainViewController.m file (present inside classes folder)
Place the following code in (void)viewWillAppear:(BOOL)animated class.

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
       CGRect viewBounds = [self.webView bounds];
       viewBounds.origin.y = 20;
       viewBounds.size.height = viewBounds.size.height - 20;
       self.webView.frame = viewBounds;
}

Continue reading

Using PhoneGap notification API to display customized alert

Introduction: In each and every mobile application we need to display customize message to user and the message should be well formatted and well designed. As we know PhoneGap application is based on JavaScript , we normally use JavaScript to display the message. But PhoneGap provides the mechanism to display well formatted message using Notification API.

 Description: As PhoneGap supports JavaScript we can use the JavaScript to show the alert but that alert will not look good in mobile devices.The alert will display with the page name as alert header. Continue reading

Detecting current postion of mobile devices using PhoneGap Geolocation API

Introduction: Geolocation is the property by which we can detect the current position of the device using latitude and longitude. We can get the location by invoking GPS(Global Positioning System) and the location obtain from network signals such as IP address, WiFi and mobile networks. PhoneGap provides the geolocation API which can be used to detect the device position by invoking the GPS. So with out using any native plugin, we can get the device geolocation simply using JavaScript.

Description: PhoneGap Geolocation API is basically based upon the W3C Geolocation API and it follows the same specification that W3C Geolocation does to detect the device latitude and longitude. So after integrating the Geolocation API, when we run the application in device it will ask for the user permission in iOS devices as per the privacy guidelines. If we cancel the permission then the app will not be able to obtain the geolocation.

Continue reading

Creating PhoneGap Android application using version 3.0.

Introduction: Previously PhoneGap was providing total package as a single version which contains all the necessary files for each platform. We are downloading the zip as a version and integrating the required files inside our Android application. It was working same till version 2.9 but from version 3.0 onwards the scenario is little different.

Description: From 3.0 onwards PhoneGap is not providing the zip file to download and integrate the same with our application. Now it is giving the install option, so we can directly install the PhoneGap into our system and use the same to create the application. Here we will focus on creating the Android application using version 3.0.

To install the PhoneGap we need some dependencies which will help PhoneGap to work properly. Continue reading