Phonegap
Installation and Using Phonegap
Do you prefer to develop web based device programs? Do you
prefer to use your wide range of customized styles with your device feature? I
prefer so i choosed phonegap. Phonegap is the old name of Cordova. Apache develops
cordova i think so fast.If you compare the versions and their dates you will
see the fast of the team.
In briefly cordova helps us to use device from js code. Js
code that we will write has lots of built in features to use device
functionalities. It does not matter the os of the device. All the de facto os
are supported. I used for android and blackberry that enchant me. They have also very effective documentations
for the new-experienced developers from a to z that they published.
Creating the normal java android is the first aim. You will
see this structure below.
However, before starting to code, firstly you should download the libraries from this link with the version you want and also you can check your feature availability from thir release posts.
http://phonegap.com/download/
http://phonegap.com/download/
The importants are src,asset, res(xml) folders and
Config.xml, AndroidManifest.xml files. You should first examine the usage
structure.
You will write your javascript code into html files that
will be in asset folder.
You will give permission to the android that if you use
device features from your javascript to the AndroidManifest.xml
You will write the cordova plug in definitions to the
config.xml file that is in xml folder of the res folder.
Then you will call your html file from your java code that
is extended from DroidGap.
Now lets code we will write a vibrating function fort he
android device.
To the AndroidManifest.xml file add this
<uses-permission android:name="android.permission.VIBRATE" />
To the xml folder config.xml add this
<plugins>
<plugin name="Device"
value="org.apache.cordova.Device"/>
<plugin name="Notification" value="org.apache.cordova.Notification"/>
</plugins>
Now lets code js.Js will use the cordova-x.y.z.js file
that you should put this file into the file you Show from src.
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>First Example</title>
<script type="text/javascript"
src="cordova-2.3.0.js"></script>
</head>
<body>
<script type=”text/javascript”>
document.addEventListener("deviceready", onDeviceReady, false);
function
onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function onDeviceReady(){
navigator.notification.vibrate(8000);
}
</script>
Hi
</body>
</html>
Now lets code the Java
package
a.b.c;
import
android.app.Activity;
import
android.os.Bundle;
public class Hi extends DroidGap {
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/yourhtml.html");
}
}
android_asset means to bring inside your asset folder.
You
will encounter some wrongs like DroidGap your should put the cordova.jar of
android to your libs folder.
After
the wrongs cleared now try if you encounter Cordova class not found try to put
your cordova.jar to your path from the properties of your Project or your
folders such as res/xml/config.xml can be wrong named.
This
framework gives a big chance for mobile developers to use wide range of styles through using the device features. When you run the application the all screen web view will be loaded to the device you run and the cordova structure will handle the device from its javascript definitions. If you examine these definitions deeply you will see the plug-in structure of the cordova that enables you to add new features maybe with this incredible framework...






