SlideShare uma empresa Scribd logo
1 de 42
PhoneGap Hardware Manipulation Accessing the device native APIs ,[object Object],[object Object],[object Object],[object Object],[object Object]
Table of Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
The Device Object ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Notification API ,[object Object],[object Object],[object Object],[object Object],navigator.notification = { alert(message, alertCallback, [title], [buttonName]),  confirm(message, confirmCallback, [title], [buttonLabels]),  vibrate(milliseconds), beep(times) }
Connection API ,[object Object],[object Object],[object Object],[object Object]
Connection API (2) ,[object Object],Connection.NONE  - No network connection detected  Connection.ETHERNET - LAN network connection  Connection.WIFI  - Wireless B/G/N connection type  Connection.CELL_2G  - 2G connection type- GPRS or EDGE (2.5G) Connection.CELL_3G  - 3G HSPA connection type  Connection.CELL_4G  - LTE or WiMax connection type  Connection.UNKNOWN  - the connection type cannot be determined
Connection API (3) function checkConnection() {     var networkState = navigator.network. connection.type ;     var states = {};     states[ Connection .UNKNOWN]  = 'Unknown connection';     states[ Connection .ETHERNET] = 'Ethernet connection';     states[ Connection .WIFI]     = 'WiFi connection';     states[ Connection .CELL_2G]  = 'Cell 2G connection';     states[ Connection .CELL_3G]  = 'Cell 3G connection';     states[ Connection .CELL_4G]  = 'Cell 4G connection';     states[ Connection .NONE]     = 'No network connection';     alert(' Connection  type: ' + states[networkState]); } checkConnection();
Events ,[object Object],[object Object],[object Object],[object Object]
The deviceready event ,[object Object],[object Object],document.addEventListener("deviceready",  onDeviceReady,    false); function onDeviceReady() { // Fill out the PhoneGap version  $("#phonegap_version").text(device.phonegap); }
The pause/resume events ,[object Object],[object Object],[object Object],[object Object]
The pause/resume events (2) document.addEventListener("pause", onPause, false); document.addEventListener("resume", onResume, false); function onPause() {  navigator.compass.clearWatch(compassId); } function onResume() {    compassId = navigator.compass .watchHeading( function (heading) { // do something }); }
The online/offline Events ,[object Object],[object Object],document.addEventListener("online", onOnline, false); document.addEventListener("offline", onOffline, false); function onOnline() {  // Handle the online event  } function onOffline() {  // Handle the offline event  }
The batterystatus / batterylow / batterycritical events ,[object Object],[object Object],[object Object]
The batterystatus / batterylow / batterycritical events (2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Button Events ,[object Object],[object Object],backbutton (Android and BlackBerry) menubutton (Android and BlackBerry) searchbutton (Android) startcallbutton (BlackBerry) endcallbutton (BlackBerry) volumedownbutton (BlackBerry) volumeupbutton (BlackBerry)
Compass (1) ,[object Object],[object Object]
Compass (2) ,[object Object],navigator.compass = {  getCurrentHeading (compassSuccess, [compassError],    [compassOptions]), int  watchHeading (compassSuccess, [compassError],    [compassOptions]),  clearWatch (watchId),  int  watchHeadingFilter (compassSuccess, [compassError],    [compassOptions]), // Only on iOS.   clearWatchFilter (watchId) // Only on iOS. }
Compass (3) ,[object Object],CompassHeading = {  magneticHeading : The heading in degrees from 0-359.99, trueHeading : The heading relative to the geographic North in degrees 0-359.99. A negative value indicates that the true heading could not be determined. Some platforms return directly the magnetic heading instead, headingAccuracy : The deviation in degrees between the reported heading and the true heading, timestamp : The timestamp of the reading }
Compass (4) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Compass Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Accelerometer (1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Accelerometer (2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Accelerometer Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Geolocation (1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Geolocation (2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Geolocation (3) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Geolocation (4) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Geolocation (5) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Geolocation Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Camera (1) ,[object Object],[object Object],[object Object],navigator.camera.getPicture(onSuccess,  onFail,  [Settings]);
Camera (2) ,[object Object],cameraOptions = {  quality : Quality of saved image - range [0, 100],  destinationType : DATA_URL or FILE_URI,  sourceType : CAMERA, PHOTOLIBRARY or SAVEDPHOTOALBUM, mediaType : PICTURE, VIDEO, ALLMEDIA, allowEdit : Allow simple editing of image before selection, encodingType : JPEG or PNG, targetWidth : Width in pixels to scale image, targetHeight : Height in pixels to scale image };
Camera Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Contacts (1) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],contact = navigator.contacts.create({"displayName": "Test User"});
Contacts (2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Contacts (3) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],{ save (onSuccess, [onError]) – saves the contact in the device, clone () – clones the contact and sets its ID to null, remove (onSuccess, [onError]) – removes a contact }
Contacts (5) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Contacts (6) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],ContactField = { type : The field type (example: ‘office'), value : The value of the field (such as a phone number or email address) }
Contacts (7) ,[object Object],[object Object],[object Object],[object Object],ContactFindOptions = { filter : Search string to filter contacts - default "", multiple : Should return multiple results – default false } ContactError.UNKNOWN_ERROR, ContactError.INVALID_ARGUMENT_ERROR, ContactError.TIMEOUT_ERROR, ContactError.PENDING_OPERATION_ERROR, ContactError.IO_ERROR, ContactError.NOT_SUPPORTED_ERROR, ContactError.PERMISSION_DENIED_ERROR
Contacts Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Homework ,[object Object],[object Object]

Mais conteúdo relacionado

Semelhante a PhoneGap - Hardware Manipulation

Error ontologies and altarica transformation aadl meeting florida jan 24-27
Error ontologies and altarica transformation   aadl meeting florida jan 24-27Error ontologies and altarica transformation   aadl meeting florida jan 24-27
Error ontologies and altarica transformation aadl meeting florida jan 24-27
Vangelis Vassiliadis
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCAndroid Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Jim Tochterman
 
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
Frédéric Harper
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Robert Nyman
 
Using AIR for Mobile Development
Using AIR for Mobile DevelopmentUsing AIR for Mobile Development
Using AIR for Mobile Development
Veronique Brossier
 

Semelhante a PhoneGap - Hardware Manipulation (20)

Error ontologies and altarica transformation aadl meeting florida jan 24-27
Error ontologies and altarica transformation   aadl meeting florida jan 24-27Error ontologies and altarica transformation   aadl meeting florida jan 24-27
Error ontologies and altarica transformation aadl meeting florida jan 24-27
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCAndroid Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
 
W 0300 codingfor_life-batterylifethatis
W 0300 codingfor_life-batterylifethatisW 0300 codingfor_life-batterylifethatis
W 0300 codingfor_life-batterylifethatis
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming En
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScriptMobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScript
 
Pandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 AgentPandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 Agent
 
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
Firefox OS, a startup opportunity - Mobile Startups Toronto & HTML Toronto me...
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 
Android wearpp
Android wearppAndroid wearpp
Android wearpp
 
Advantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processingAdvantages and limitations of PhoneGap for sensor processing
Advantages and limitations of PhoneGap for sensor processing
 
Camera And Email
Camera And EmailCamera And Email
Camera And Email
 
Using AIR for Mobile Development
Using AIR for Mobile DevelopmentUsing AIR for Mobile Development
Using AIR for Mobile Development
 
15 sensors and proximity nfc and bluetooth
15   sensors and proximity nfc and bluetooth15   sensors and proximity nfc and bluetooth
15 sensors and proximity nfc and bluetooth
 
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
HTML for the Mobile Web, Firefox OS - All Things Open - 2014-10-22
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash Professional
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
Alberto Guarino "When iPhones and Wearables Dance the Bluetooth Dance: Lesson...
Alberto Guarino "When iPhones and Wearables Dance the Bluetooth Dance: Lesson...Alberto Guarino "When iPhones and Wearables Dance the Bluetooth Dance: Lesson...
Alberto Guarino "When iPhones and Wearables Dance the Bluetooth Dance: Lesson...
 
Taming event-driven software via formal verification
Taming event-driven software via formal verificationTaming event-driven software via formal verification
Taming event-driven software via formal verification
 

Mais de Doncho Minkov

Mais de Doncho Minkov (20)

Web Design Concepts
Web Design ConceptsWeb Design Concepts
Web Design Concepts
 
Web design Tools
Web design ToolsWeb design Tools
Web design Tools
 
HTML 5
HTML 5HTML 5
HTML 5
 
HTML 5 Tables and Forms
HTML 5 Tables and FormsHTML 5 Tables and Forms
HTML 5 Tables and Forms
 
CSS Overview
CSS OverviewCSS Overview
CSS Overview
 
CSS Presentation
CSS PresentationCSS Presentation
CSS Presentation
 
CSS Layout
CSS LayoutCSS Layout
CSS Layout
 
CSS 3
CSS 3CSS 3
CSS 3
 
Adobe Photoshop
Adobe PhotoshopAdobe Photoshop
Adobe Photoshop
 
Slice and Dice
Slice and DiceSlice and Dice
Slice and Dice
 
Introduction to XAML and WPF
Introduction to XAML and WPFIntroduction to XAML and WPF
Introduction to XAML and WPF
 
WPF Layout Containers
WPF Layout ContainersWPF Layout Containers
WPF Layout Containers
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
WPF Templating and Styling
WPF Templating and StylingWPF Templating and Styling
WPF Templating and Styling
 
WPF Graphics and Animations
WPF Graphics and AnimationsWPF Graphics and Animations
WPF Graphics and Animations
 
Simple Data Binding
Simple Data BindingSimple Data Binding
Simple Data Binding
 
Complex Data Binding
Complex Data BindingComplex Data Binding
Complex Data Binding
 
WPF Concepts
WPF ConceptsWPF Concepts
WPF Concepts
 
Model View ViewModel
Model View ViewModelModel View ViewModel
Model View ViewModel
 
WPF and Databases
WPF and DatabasesWPF and Databases
WPF and Databases
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

PhoneGap - Hardware Manipulation

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Connection API (3) function checkConnection() {     var networkState = navigator.network. connection.type ;     var states = {};     states[ Connection .UNKNOWN]  = 'Unknown connection';     states[ Connection .ETHERNET] = 'Ethernet connection';     states[ Connection .WIFI]     = 'WiFi connection';     states[ Connection .CELL_2G]  = 'Cell 2G connection';     states[ Connection .CELL_3G]  = 'Cell 3G connection';     states[ Connection .CELL_4G]  = 'Cell 4G connection';     states[ Connection .NONE]     = 'No network connection';     alert(' Connection type: ' + states[networkState]); } checkConnection();
  • 9.
  • 10.
  • 11.
  • 12. The pause/resume events (2) document.addEventListener("pause", onPause, false); document.addEventListener("resume", onResume, false); function onPause() { navigator.compass.clearWatch(compassId); } function onResume() { compassId = navigator.compass .watchHeading( function (heading) { // do something }); }
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.

Notas do Editor

  1. Когато PhoneGap се инициализира, той създава няколко обекта (повечето от тях в window.navigator), за да подпомогне комуникацията между вашата апликация и устройството под нея. { name: Може също да върне име на продукта в Андроид или името на собственика на телефона в iOS, platform: iOS връща iPhone като име на операционната си система вместо правилното iOS , уникалният идентификатор се генерира по различен начин на всяка платформа version: Windows Phone връща пълната версия , например 7.10.xxxx }
  2. Alert и Confirm се предоставени като заместници на системните такива диалози, за да може да се промени изгледът им (имена на бутони, заглавие). Някои платформи не спират изпълнението на джаваскрипт когато показват системните диалози и това е добър начин за заобикалянеъо на този проблем. Във Windows Phone бутоните не могат да се променят. Във iOS PhoneGap игнорира аргументите на vibrate() и beep() – файлът трябва да е по-къс от 30 секунди и да се намира във главната директория на HTML приложението със името beep.wav
  3. Има и изключения – някои мобилни операционни системи не спират изпълнението на апликациите и те продължават да работят в background.
  4. altitudeAccuracy не се поддържа в Android и винаги ще върне null.
  5. Аргумента allowEdit е достъпен само в iOS. quality, mediaType и sourceType се игнорират в BlackBerry Palm encodingType не се поддържа в Android
  6. Категориите се поддържат само в BlackBerry и то само отчасти .