PhoneGap API

HTML5

device

device

device example

script
  x$(window).load(function(){
    x$("#platform").inner(device.platform);
    x$("#version").inner(device.version);
    x$("#name").inner(device.name);
    x$("#uuid").inner(device.uuid);
  });
body
  <ul>
    <li id="platform"></li>
    <li id="version"></li>
    <li id="name"></li>
    <li id="uuid"></li>
  </ul>

vibrate

navigator.notification.vibrate(0);

vibration example

script
  x$('a.vibrate').touchstart(function(e){ navigator.notification.vibrate(0); })
body
  <a href="#" class="vibrate">feels good</a>

beep

navigator.notification.beep(2);

beep example

script
  x$('a.beep').touchstart(function(e){ navigator.notification.beep(2); })
body
  <a href="#" class="beep">hey listen!</a>

telephony

tell:411

telephony example

body
  <a href="tel:411">Call 411</a>

geolocation

navigator.geolocation.getCurrentPosition(win, fail);

geolocation example

var getLocation = function() {

  var win = function(p){
    alert(p.coords.latitude + " " + p.coords.longitude);
  };
  var fail = function(){};
  
  navigator.geolocation.getCurrentPosition(win, fail);
}

accelerometer

navigator.accelerometer.watchAcceleration(win, fail, opt);

accelerometer example

function watchAccel() {
  var win = function(a){
    x$('#x').innerHTML = a.x;
    x$('#y').innerHTML = a.y;
    x$('#z').innerHTML = a.z;
  };
  var fail = function(){};
  var opt = {};
  opt.frequency = 100;
  timer = navigator.accelerometer.watchAcceleration(win, fail, opt);
}

Questions?