Irek Róg
PhoneGap (full name: Adobe PhoneGap) is an open source framework for quickly building cross-platform mobile apps using HTML5, CSS and JavaScript.
PhoneGap is a distributon of Apache Cordova. PhoneGap distribution contains additional tools like:
http://nodejs.org/en/
$ npm install -g phonegap@latest$ phonegap create MyFirstApp$ cd MyFirstApp$ dirconfig.xml hooks/ platforms/ plugins/ www/config.xml - application configure file
hooks - scripts which could be added by application
platforms - a catalog contains files of added platform
plugins - a catalog with added plugins
www -
$ cd www$ dircss/ icon.png img/ index.html js/ res/ spec/ spec.htmlThis catalog contains HTML, CSS and JavaScript files which we can edit to creat our application.
$ phonegap platform add <platform>$ phonegap platform add wp8
$ phonegap platform add windows
$ phonegap platform add amazon-fireos
$ phonegap platform add android
$ phonegap platform add blackberry10
$ phonegap platform add firefoxos
$ phonegap platform add browserPossible options:
Windows
Mac
$ phonegap platform add ios
$ phonegap platform add amazon-fireos
$ phonegap platform add android
$ phonegap platform add blackberry10
$ phonegap platform add firefoxos
$ phonegap platform add browser$ phonegap build <platform>This command generates platform-specific code within the project's platforms subdirectory.
$ phonegap emulate <added_platform>$ phonegap run <added_platform>By default the run command will look for a connected device, if no device is found it will look for any started emulators. If you have multiple emulators, you can specify a target ID.
1. Install PhoneGap Developer App
(from Google Play, Windows Phone Store or iTunes)
2. Wirelessly pair the apps
Now that we have paired devices, as we change the source code the mobile app will instantly show our latest changes.
A plugin is a bit of add-on code that provides an interface to native components.
$ phonegap plugin add <name_of_plugin>We can design own plugin interface, but more commonly, we would add a plugin to enable one of basic device-level features detailed in the API Reference.
phonegap plugin add cordova-plugin-battery-statusExample for Android
// Battery status
function onBatteryStatus(info) {
document.getElementById("current-state").innerHTML = info.level + "%";
}
function checkBattery() {
window.addEventListener("batterystatus", onBatteryStatus, false);
}
window.onload=checkBattery;Next add simply JavaScript code:
We add plugin of battery status:
Text
Result
Advantages
Disadvantages