SlideShare a Scribd company logo
1 of 19
PhoneGap for Mobile Application
        Development
             Yiguang Hu
         yighu@yahoo.com
people don't go to Google on
     this, they go to Yelp
           Steve Jobs
PhoneGap/Cordova
an HTML5 app platform that allows you to
    author native applications with web
technologies and get access to APIs and app
                   stores
How it works
• Build once with Web-standards
• Wrap it with PhoneGap
• Deploy to Multiple platforms
•   HTML5+CSS3
•   JavaScript
•   Native Features
•   Deploy to multiple Platforms
Features
APIs-Accelerometer
function onSuccess(acceleration) {
     alert('Acceleration X: ' + acceleration.x + 'n' +
        'Acceleration Y: ' + acceleration.y + 'n' +
        'Acceleration Z: ' + acceleration.z + 'n' +
        'Timestamp: ' + acceleration.timestamp + 'n');
  };
  function onError() {
     alert('onError!');
  };
  navigator.accelerometer.getCurrentAcceleration(onSuccess,
  onError);
APIs-geolocation
varonSuccess = function(position) {
      alert('Latitude: '    + position.coords.latitude       + 'n' +
         'Longitude: '     + position.coords.longitude        + 'n' +
         'Altitude: '    + position.coords.altitude       + 'n' +
         'Accuracy: '     + position.coords.accuracy        + 'n' +
         'Altitude Accuracy: ' + position.coords.altitudeAccuracy + 'n' +
         'Heading: '      + position.coords.heading         + 'n' +
         'Speed: '       + position.coords.speed          + 'n' +
         'Timestamp: '      + new Date(position.timestamp) + 'n');
   };

   function onError(error) {
     alert('code: ' + error.code + 'n' +
         'message: ' + error.message + 'n');
   }
   navigator.geolocation.getCurrentPosition(onSuccess, onError);
APIs-Storage
function populateDB(tx) {
       tx.executeSql('DROP TABLE IF EXISTS DEMO');
       tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
       tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
       tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
   }
   function errorCB(err) {
     alert("Error processing SQL: "+err.code);
   }
   function successCB() {
     alert("success!");
   }
   var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
   db.transaction(populateDB, errorCB, successCB);
APIs-Storage
function queryDB(tx) {
tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
}

function querySuccess(tx, results) {
varlen = results.rows.length;
console.log("DEMO table: " + len + " rows found.");

for (vari=0; i<len; i++){console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data = " +
     results.rows.item(i).data);
  }
}

function errorCB(err) {
alert("Error processing SQL: "+err.code);
}

var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
db.transaction(queryDB, errorCB);
Demonstration
• Download and install PhoneGap
  – http://phonegap.com/
• Develop your web application and wrap it
  with Phonegap
• Drop www to target platform projects
• Test/Run
• Deploy it!
Android demo

1. Requirements
  – Eclipse 3.4+
2. Install SDK + PhoneGap
  – Download and install Eclipse Classic
  – Download and install Android SDK
  – Download and install ADT Plugin
  – Donwload the latest copy of PhoneGap and
    extract its contents.
Android demo continue…

3. Create Android project
4. Under project root
  – Create libs and assets/www
Android demo continue…

5. Copy from phonegap root/libs/android
  – example/assets/www/* to assets/www
  – cordova-1.5.0.jar to libs/
  – xml folder to /res
cordova.js file for different platforms are not
                 interchangeable!
Android demo continue…
5. Refresh the project
6. Update activity code
  – Add cordova.jar into build path
  – Change the class's extend from Activity to DroidGap
  – Replace the setContentView() line with
    super.loadUrl("file:///android_asset/www/index.ht
    ml");
  – Add import org.apache.cordova.DroidGap;
  – Add import com.phonegap.*;
  – Remove import android.app.Activity;
iPhone Demo
• InstallXcode
• Install PhoneGap
   – Open and install from Cordova-1.5.0.dmg
• Create a new project
   •   Select PhoneGap/cordova-based Application
• Run it
• Drag the www directory by the iosphonegap project
  directory into project
• Run it again
• Copy the html files developed from Android into the ios
  project www directory
• Run it again
Windows phone demo
• Require Windows 7 or Windows Vista with SP2
• JDK 32bit
• Install
   – Windows Phone SDK and phonegap
• Setup
   – Open Visual Studio Express for Windows Phone and
     choose New Project.
   – Select PhoneGapStarter.
   – Drag www folder and drop into project
   – Copy the app related files into www folder
• Build and run
PhoneGap for Mobile Application
        Development
             Yiguang Hu
         yighu@yahoo.com
           yighu@twitter

More Related Content

What's hot

2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-newBradDesAulniers2
 
Node.js Everywhere by @zwigby
Node.js Everywhere by @zwigbyNode.js Everywhere by @zwigby
Node.js Everywhere by @zwigbyCharlie Key
 
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28Frédéric Harper
 
The State of the Developer Ecosystem - .NET Conf Barcelona 2018
The State of the Developer Ecosystem - .NET Conf Barcelona 2018The State of the Developer Ecosystem - .NET Conf Barcelona 2018
The State of the Developer Ecosystem - .NET Conf Barcelona 2018Carlos Mendible
 
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12Frédéric Harper
 
ServiceWorker: Exploring the Core of the Progressive Web App-Bagus Aji Santos...
ServiceWorker: Exploring the Core of the Progressive Web App-Bagus Aji Santos...ServiceWorker: Exploring the Core of the Progressive Web App-Bagus Aji Santos...
ServiceWorker: Exploring the Core of the Progressive Web App-Bagus Aji Santos...DicodingEvent
 
V8 javascript engine for フロントエンドデベロッパー
V8 javascript engine for フロントエンドデベロッパーV8 javascript engine for フロントエンドデベロッパー
V8 javascript engine for フロントエンドデベロッパーTaketoshi 青野健利
 
Secret Deployment Events API features for mabl
Secret Deployment Events API features for mablSecret Deployment Events API features for mabl
Secret Deployment Events API features for mablMatthew Stein
 
Future of Development and Deployment using Docker
Future of Development and Deployment using DockerFuture of Development and Deployment using Docker
Future of Development and Deployment using DockerTamer Abdul-Radi
 
Locarise,reagent and JavaScript Libraries
Locarise,reagent and JavaScript LibrariesLocarise,reagent and JavaScript Libraries
Locarise,reagent and JavaScript LibrariesIkuru Kanuma
 
Debug production server by counter
Debug production server by counterDebug production server by counter
Debug production server by counterRoy Chung-Cheng Lou
 
Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular Jalpesh Vadgama
 
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java GirlFull-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java GirlLoiane Groner
 
What's new in c# 8.0
What's new in c# 8.0What's new in c# 8.0
What's new in c# 8.0Moaid Hathot
 
Reusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/RhinoReusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/RhinoKenneth Kalmer
 
FullStack Reativo com Spring WebFlux + Angular
FullStack Reativo com Spring WebFlux + AngularFullStack Reativo com Spring WebFlux + Angular
FullStack Reativo com Spring WebFlux + AngularLoiane Groner
 
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019Loiane Groner
 
Gigigo Rails Workshop
Gigigo Rails WorkshopGigigo Rails Workshop
Gigigo Rails WorkshopAlex Rupérez
 

What's hot (20)

2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new
 
非同期javascriptの過去と未来
非同期javascriptの過去と未来非同期javascriptの過去と未来
非同期javascriptの過去と未来
 
Node.js Everywhere by @zwigby
Node.js Everywhere by @zwigbyNode.js Everywhere by @zwigby
Node.js Everywhere by @zwigby
 
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
Firefox OS, fixing the mobile web - FITC Toronto - 2014-04-28
 
The State of the Developer Ecosystem - .NET Conf Barcelona 2018
The State of the Developer Ecosystem - .NET Conf Barcelona 2018The State of the Developer Ecosystem - .NET Conf Barcelona 2018
The State of the Developer Ecosystem - .NET Conf Barcelona 2018
 
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
Firefox OS, HTML5 to the next level - Python Montreal - 2014-05-12
 
ServiceWorker: Exploring the Core of the Progressive Web App-Bagus Aji Santos...
ServiceWorker: Exploring the Core of the Progressive Web App-Bagus Aji Santos...ServiceWorker: Exploring the Core of the Progressive Web App-Bagus Aji Santos...
ServiceWorker: Exploring the Core of the Progressive Web App-Bagus Aji Santos...
 
Let's migrate to Swift 3.0
Let's migrate to Swift 3.0Let's migrate to Swift 3.0
Let's migrate to Swift 3.0
 
V8 javascript engine for フロントエンドデベロッパー
V8 javascript engine for フロントエンドデベロッパーV8 javascript engine for フロントエンドデベロッパー
V8 javascript engine for フロントエンドデベロッパー
 
Secret Deployment Events API features for mabl
Secret Deployment Events API features for mablSecret Deployment Events API features for mabl
Secret Deployment Events API features for mabl
 
Future of Development and Deployment using Docker
Future of Development and Deployment using DockerFuture of Development and Deployment using Docker
Future of Development and Deployment using Docker
 
Locarise,reagent and JavaScript Libraries
Locarise,reagent and JavaScript LibrariesLocarise,reagent and JavaScript Libraries
Locarise,reagent and JavaScript Libraries
 
Debug production server by counter
Debug production server by counterDebug production server by counter
Debug production server by counter
 
Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular Top 10 RxJs Operators in Angular
Top 10 RxJs Operators in Angular
 
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java GirlFull-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
Full-Stack Reativo com Spring WebFlux + Angular - Devs Java Girl
 
What's new in c# 8.0
What's new in c# 8.0What's new in c# 8.0
What's new in c# 8.0
 
Reusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/RhinoReusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/Rhino
 
FullStack Reativo com Spring WebFlux + Angular
FullStack Reativo com Spring WebFlux + AngularFullStack Reativo com Spring WebFlux + Angular
FullStack Reativo com Spring WebFlux + Angular
 
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
Full-Stack Reactive with Spring WebFlux + Angular - JConf Colombia 2019
 
Gigigo Rails Workshop
Gigigo Rails WorkshopGigigo Rails Workshop
Gigigo Rails Workshop
 

Similar to Phone Gap

Introduction to PhoneGap
Introduction to PhoneGapIntroduction to PhoneGap
Introduction to PhoneGapYagiz Nizipli
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)ejlp12
 
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache CordovaHazem Saleh
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Davide Cerbo
 
Non Conventional Android Programming En
Non Conventional Android Programming EnNon Conventional Android Programming En
Non Conventional Android Programming Enguest9bcef2f
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformRobert Nyman
 
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
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09Frédéric Harper
 
Apache Cordova In Action
Apache Cordova In ActionApache Cordova In Action
Apache Cordova In ActionHazem Saleh
 
[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In ActionHazem Saleh
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on MobileAdam Lu
 
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-22Frédéric Harper
 
Phone gap 12 things you should know
Phone gap 12 things you should knowPhone gap 12 things you should know
Phone gap 12 things you should knowISOCHK
 
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22Frédéric Harper
 
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...Frédéric Harper
 

Similar to Phone Gap (20)

Introduction to PhoneGap
Introduction to PhoneGapIntroduction to PhoneGap
Introduction to PhoneGap
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
 
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
 
Oracle APEX & PhoneGap
Oracle APEX & PhoneGapOracle APEX & PhoneGap
Oracle APEX & PhoneGap
 
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
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
 
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...
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
Firefox OS, une plateforme à découvrir - IO Saglac - 2014-09-09
 
Apache Cordova In Action
Apache Cordova In ActionApache Cordova In Action
Apache Cordova In Action
 
[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
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
 
Phone gap 12 things you should know
Phone gap 12 things you should knowPhone gap 12 things you should know
Phone gap 12 things you should know
 
PhoneGap
PhoneGapPhoneGap
PhoneGap
 
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
Firefox OS: HTML5 sur les stéroïdes - HTML5mtl - 2014-04-22
 
mobl
moblmobl
mobl
 
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
HTML, not just for desktops: Firefox OS - Congreso Universitario Móvil - 201...
 

More from Yiguang Hu

Data analysis scala_spark
Data analysis scala_sparkData analysis scala_spark
Data analysis scala_sparkYiguang Hu
 
Java8 and Functional Programming
Java8 and Functional ProgrammingJava8 and Functional Programming
Java8 and Functional ProgrammingYiguang Hu
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.xYiguang Hu
 
Cross platform Mobile development on Titanium
Cross platform Mobile development on TitaniumCross platform Mobile development on Titanium
Cross platform Mobile development on TitaniumYiguang Hu
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 

More from Yiguang Hu (10)

Data analysis scala_spark
Data analysis scala_sparkData analysis scala_spark
Data analysis scala_spark
 
Java8 and Functional Programming
Java8 and Functional ProgrammingJava8 and Functional Programming
Java8 and Functional Programming
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
 
Cross platform Mobile development on Titanium
Cross platform Mobile development on TitaniumCross platform Mobile development on Titanium
Cross platform Mobile development on Titanium
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Clojure
ClojureClojure
Clojure
 
Why Grails
Why GrailsWhy Grails
Why Grails
 
Why Grails?
Why Grails?Why Grails?
Why Grails?
 
Gsword
GswordGsword
Gsword
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 

Phone Gap

  • 1. PhoneGap for Mobile Application Development Yiguang Hu yighu@yahoo.com
  • 2. people don't go to Google on this, they go to Yelp Steve Jobs
  • 3. PhoneGap/Cordova an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores
  • 4. How it works • Build once with Web-standards • Wrap it with PhoneGap • Deploy to Multiple platforms
  • 5. HTML5+CSS3 • JavaScript • Native Features • Deploy to multiple Platforms
  • 7. APIs-Accelerometer function onSuccess(acceleration) { alert('Acceleration X: ' + acceleration.x + 'n' + 'Acceleration Y: ' + acceleration.y + 'n' + 'Acceleration Z: ' + acceleration.z + 'n' + 'Timestamp: ' + acceleration.timestamp + 'n'); }; function onError() { alert('onError!'); }; navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
  • 8. APIs-geolocation varonSuccess = function(position) { alert('Latitude: ' + position.coords.latitude + 'n' + 'Longitude: ' + position.coords.longitude + 'n' + 'Altitude: ' + position.coords.altitude + 'n' + 'Accuracy: ' + position.coords.accuracy + 'n' + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + 'n' + 'Heading: ' + position.coords.heading + 'n' + 'Speed: ' + position.coords.speed + 'n' + 'Timestamp: ' + new Date(position.timestamp) + 'n'); }; function onError(error) { alert('code: ' + error.code + 'n' + 'message: ' + error.message + 'n'); } navigator.geolocation.getCurrentPosition(onSuccess, onError);
  • 9. APIs-Storage function populateDB(tx) { tx.executeSql('DROP TABLE IF EXISTS DEMO'); tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)'); tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")'); tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")'); } function errorCB(err) { alert("Error processing SQL: "+err.code); } function successCB() { alert("success!"); } var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000); db.transaction(populateDB, errorCB, successCB);
  • 10. APIs-Storage function queryDB(tx) { tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB); } function querySuccess(tx, results) { varlen = results.rows.length; console.log("DEMO table: " + len + " rows found."); for (vari=0; i<len; i++){console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data = " + results.rows.item(i).data); } } function errorCB(err) { alert("Error processing SQL: "+err.code); } var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000); db.transaction(queryDB, errorCB);
  • 11. Demonstration • Download and install PhoneGap – http://phonegap.com/ • Develop your web application and wrap it with Phonegap • Drop www to target platform projects • Test/Run • Deploy it!
  • 12. Android demo 1. Requirements – Eclipse 3.4+ 2. Install SDK + PhoneGap – Download and install Eclipse Classic – Download and install Android SDK – Download and install ADT Plugin – Donwload the latest copy of PhoneGap and extract its contents.
  • 13. Android demo continue… 3. Create Android project 4. Under project root – Create libs and assets/www
  • 14. Android demo continue… 5. Copy from phonegap root/libs/android – example/assets/www/* to assets/www – cordova-1.5.0.jar to libs/ – xml folder to /res
  • 15. cordova.js file for different platforms are not interchangeable!
  • 16. Android demo continue… 5. Refresh the project 6. Update activity code – Add cordova.jar into build path – Change the class's extend from Activity to DroidGap – Replace the setContentView() line with super.loadUrl("file:///android_asset/www/index.ht ml"); – Add import org.apache.cordova.DroidGap; – Add import com.phonegap.*; – Remove import android.app.Activity;
  • 17. iPhone Demo • InstallXcode • Install PhoneGap – Open and install from Cordova-1.5.0.dmg • Create a new project • Select PhoneGap/cordova-based Application • Run it • Drag the www directory by the iosphonegap project directory into project • Run it again • Copy the html files developed from Android into the ios project www directory • Run it again
  • 18. Windows phone demo • Require Windows 7 or Windows Vista with SP2 • JDK 32bit • Install – Windows Phone SDK and phonegap • Setup – Open Visual Studio Express for Windows Phone and choose New Project. – Select PhoneGapStarter. – Drag www folder and drop into project – Copy the app related files into www folder • Build and run
  • 19. PhoneGap for Mobile Application Development Yiguang Hu yighu@yahoo.com yighu@twitter

Editor's Notes

  1. Read more: http://www.businessinsider.com/keith-rabois-qa-with-the-square-coo-and-angel-investor-2012-4?op=1#ixzz1rbFHRYjF
  2. ADT=Android Deployment Tools