navigator.device.capture•••
navigator.device.capture
–––––
var imageModes =navigator.device.capture.supportedImageModes;for each (var mode in imageModes) {console.log(mode.type);con...
capture
• • 
var options = { limit: 2, duration: 5 };navigator.device.capture.captureAudio(win, fail, options);function win(mediaFiles)...
captureAudio
• 
var options = { limit: 3};navigator.device.capture.captureImage(win, fail,options);function win(mediaFiles) {var i;for (i=...
captureAudio
• • 
navigator.device.capture.captureVideo(win, fail, {});function win(mediaFiles) {var i;for (i=0; i<mediaFiles.length; i++) {...
CaptureError.CAPTURE_INTERNAL_ERRCaptureError.CAPTURE_APPLICATION_BUSYCaptureError.CAPTURE_INVALID_ARGUMENTCaptureError.CA...
getPicture()••
navigator.camera.getPicture(win, fail,{ quality: 50,destinationType: destinationType.FILE_URI,pictureSource.PHOTOLIBRARY})...
navigator.contactsnavigator.contacts••
navigator.contacts.create(properties)
navigator.contacts.create(properties)propertiesvar contact = navigator.contacts.create({"displayName": “Ivano“});
contacts.find
•••
var contact = navigator.contacts.create({"displayName": “Ivano“});var name = new ContactName();name.givenName = “Ivano“;na...
navigator.contacts.find(contactFields,contactSuccess,contactError,contactFindOptions);
var fields = ["displayName", "name"]; // or [“*”]navigator.contacts.find(fields, win, fail);function win(contacts) {consol...
var options = new ContactFindOptions();options.filter = “Ivano";options.multiple = true;filter = ["displayName",“birthday"...
failContactError.UNKNOWN_ERRORContactError.INVALID_ARGUMENT_ERRORContactError.TIMEOUT_ERRORContactError.PENDING_OPERATION_...
– ontouchstart, onclick, ...
document.addEventListener(EVENTNAME, onEvent, false);function onEvent() {// handle the event}
• deviceready• pause, resume• online, offline• batterycritical, batterylow, batterystatus• backbutton, menubutton, searchb...
••deviceready
pauseresume
onlineoffline
navigator.network.connectiontypeConnection.UNKNOWNConnection.ETHERNETConnection.WIFIConnection.CELL_2GConnection.CELL_3GCo...
batterycriticalbatterylowbatterycriticalbatterystatus
backbuttonmenubuttonsearchbutton
•••••
navigator.notification.alert(message,callback, [title], [button])••••
navigator.notification.alert(message,callback, [title], [buttons])••–••
navigator.notification.prompt(message,callback, [title], [buttons])••–••
navigator.notification.beep(times)•
navigator.notification.vibrate(milliseconds)•
navigator.accelerometer•••
getCurrentAcceleration(win, fail);
var watchID =navigator.accelerometer.watchAcceleration(win, fail,[options]);
clearWatch(watchID);
these values include the effect ofgravity (9.81 m/s^2)
var options = { frequency: 3000 };var watchID = navigator.accelerometer.watchAcceleration(win, fail,options);function win(...
var previousReading = {x: null, y: null, z: null};navigator.accelerometer.watchAcceleration(function (reading) {var change...
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
PhoneGap: Accessing Device Capabilities
Upcoming SlideShare
Loading in...5
×

PhoneGap: Accessing Device Capabilities

1,468

Published on

PhoneGap: Accessing Device Capabilities

This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2013.

http://www.ivanomalavolta.com

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,468
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
72
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

PhoneGap: Accessing Device Capabilities

  1. 1. navigator.device.capture•••
  2. 2. navigator.device.capture
  3. 3. –––––
  4. 4. var imageModes =navigator.device.capture.supportedImageModes;for each (var mode in imageModes) {console.log(mode.type);console.log(mode.height);console.log(mode.width);}
  5. 5. capture
  6. 6. • • 
  7. 7. var options = { limit: 2, duration: 5 };navigator.device.capture.captureAudio(win, fail, options);function win(mediaFiles) {var i;for (i=0; i<mediaFiles.length; i++) {console.log(mediaFiles[i]);}}function fail(error) {console.log(„Error with code: + error.code);}
  8. 8. captureAudio
  9. 9. • 
  10. 10. var options = { limit: 3};navigator.device.capture.captureImage(win, fail,options);function win(mediaFiles) {var i;for (i=0; i<mediaFiles.length; i++) {upload(mediaFiles[i]);}}function fail(error) {console.log(„Error with code: + error.code);}
  11. 11. captureAudio
  12. 12. • • 
  13. 13. navigator.device.capture.captureVideo(win, fail, {});function win(mediaFiles) {var i;for (i=0; i<mediaFiles.length; i++) {upload(mediaFiles[i]);}}function fail(error) {console.log(„Error with code: + error.code);}
  14. 14. CaptureError.CAPTURE_INTERNAL_ERRCaptureError.CAPTURE_APPLICATION_BUSYCaptureError.CAPTURE_INVALID_ARGUMENTCaptureError.CAPTURE_NO_MEDIA_FILESCaptureError.CAPTURE_NOT__SUPPORTED
  15. 15. getPicture()••
  16. 16. navigator.camera.getPicture(win, fail,{ quality: 50,destinationType: destinationType.FILE_URI,pictureSource.PHOTOLIBRARY});function win(imageURI) {var element = $(“#block”);element.src(imageURI);}// fail function omitted here
  17. 17. navigator.contactsnavigator.contacts••
  18. 18. navigator.contacts.create(properties)
  19. 19. navigator.contacts.create(properties)propertiesvar contact = navigator.contacts.create({"displayName": “Ivano“});
  20. 20. contacts.find
  21. 21. •••
  22. 22. var contact = navigator.contacts.create({"displayName": “Ivano“});var name = new ContactName();name.givenName = “Ivano“;name.familyName = “Malavolta“;contact.name = name;contact.birthday = new Date(“19 July 1983");contact.save(win, fail);function win(contact) {alert("Save Success");};function fail(contactError) {alert("Error = " + contactError.code);};
  23. 23. navigator.contacts.find(contactFields,contactSuccess,contactError,contactFindOptions);
  24. 24. var fields = ["displayName", "name"]; // or [“*”]navigator.contacts.find(fields, win, fail);function win(contacts) {console.log(„ok);};function fail(err) {console.log(err.code);};
  25. 25. var options = new ContactFindOptions();options.filter = “Ivano";options.multiple = true;filter = ["displayName",“birthday"];navigator.contacts.find(filter, win, fail, options);function win(contacts) {for (var i=0; i<contacts.length; i++) {console.log(contacts[i].displayName);}};function fail(contactError) {alert("Error = " + contactError.code);};
  26. 26. failContactError.UNKNOWN_ERRORContactError.INVALID_ARGUMENT_ERRORContactError.TIMEOUT_ERRORContactError.PENDING_OPERATION_ERRORContactError.IO_ERRORContactError.NOT_SUPPORTED_ERRORContactError.PERMISSION_DENIED_ERROR
  27. 27. – ontouchstart, onclick, ...
  28. 28. document.addEventListener(EVENTNAME, onEvent, false);function onEvent() {// handle the event}
  29. 29. • deviceready• pause, resume• online, offline• batterycritical, batterylow, batterystatus• backbutton, menubutton, searchbutton• startcallbutton, endcallbutton• volumedownbutton, volumeupbutton
  30. 30. ••deviceready
  31. 31. pauseresume
  32. 32. onlineoffline
  33. 33. navigator.network.connectiontypeConnection.UNKNOWNConnection.ETHERNETConnection.WIFIConnection.CELL_2GConnection.CELL_3GConnection.CELL_4GConnection.NONE
  34. 34. batterycriticalbatterylowbatterycriticalbatterystatus
  35. 35. backbuttonmenubuttonsearchbutton
  36. 36. •••••
  37. 37. navigator.notification.alert(message,callback, [title], [button])••••
  38. 38. navigator.notification.alert(message,callback, [title], [buttons])••–••
  39. 39. navigator.notification.prompt(message,callback, [title], [buttons])••–••
  40. 40. navigator.notification.beep(times)•
  41. 41. navigator.notification.vibrate(milliseconds)•
  42. 42. navigator.accelerometer•••
  43. 43. getCurrentAcceleration(win, fail);
  44. 44. var watchID =navigator.accelerometer.watchAcceleration(win, fail,[options]);
  45. 45. clearWatch(watchID);
  46. 46. these values include the effect ofgravity (9.81 m/s^2)
  47. 47. var options = { frequency: 3000 };var watchID = navigator.accelerometer.watchAcceleration(win, fail,options);function win(acc) {if((acc.x == 0) && (acc.y == 0) && (acc.z == 9,81)) {console.log(“I am on a table”);stop();}}function fail() {console.log(“error”);}function stop() {if(watchID) {navigator.accelerometer.clearWatch(watchID);watchID = null;}}
  48. 48. var previousReading = {x: null, y: null, z: null};navigator.accelerometer.watchAcceleration(function (reading) {var changes = {},bound = 3;if (previousReading.x !== null) {changes.x = Math.abs(previousReading.x, reading.x);changes.y = Math.abs(previousReading.y, reading.y);changes.z = Math.abs(previousReading.z, reading.z);}if (changes.x > bound && changes.y > bound && changes.z > bound) {console.log(“shake detected”);}previousReading = {x: reading.x,y: reading.y,z: reading.z}}, null, { frequency: 300 });
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×