13. PhoneGap APIs
Accelerometer File
Tap into the device’s motion sensor. Hook into native file system through JavaScript.
Camera Geolocation
Capture a photo using the device's camera. Make your application location aware.
Compass Media
Obtain the direction that the device is pointing. Record and play back audio files.
Contacts Network
Work with the devices contact database. Quickly check the network state.
Device Notification
Gather device specific information. Visual, audible, and tactile device notifications.
Events Storage
Hook into native events through JavaScript. Hook into the device’s native storage options.
29. How it works
package com.phonegap.exampleapp;
import android.os.Bundle;
import com.phonegap.*;
public class exampleapp extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
47. Accelerometer File
Tap into the device’s motion sensor. Hook into native file system through JavaScript.
Camera Geolocation
Capture a photo using the device's camera. Make your application location aware.
Compass Media
Obtain the direction that the device is pointing. Record and play back audio files.
Contacts Network
Work with the devices contact database. Quickly check the network state.
Device Notification
Gather device specific information. Visual, audible, and tactile device notifications.
Events Storage
Hook into native events through JavaScript. Hook into the device’s native storage options.
57. Camera
navigator.camera.getPicture(
function(imageData) {
var img = document.getElementById('img');
img.src = "data:image/jpeg;base64," +
imageData;
},
function (message) {
alert('Failed because: ' + message);
},
{ quality: 50 }
);
58. File I/O
var paths = navigator.fileMgr.getRootPaths();
var file = paths[0] + "write.txt";
var writer = new FileWriter(file);
writer.onwrite = function () {};
writer.write("Hello Croatia!");
var reader = new FileReader();
reader.onload = function (e) {
alert(e.target.result);
};
reader.readAsText(file);