PhoneGap in a Day
with Troy Miles aka @therockncoder
Monday, June 3, 13
Free mobile tutorials with source
code @ therockncoder.blogspot.com
Monday, June 3, 13
Want more? Follow me, new tutorials are
announced on Twitter first:
@therockncoder
Monday, June 3, 13
Source code for my tutorials hosted on
GitHub @
https://github.com/Rockncoder
Monday, June 3, 13
Check out my videos:
www.youtube.com/rockncoder
Monday, June 3, 13
Schedule
• 8:00 Morning Session 1
• 10:00 Break
• 10:15 Morning Session 2
• 12:00 Lunch
• 12:45 Afternoon Session 1
Monday, June 3, 13
Schedule
• 2:45 Break
• 3:00 Afternoon Session 2
• 4:45 Wrap Up
Monday, June 3, 13
Where Is?
• Water
• Restrooms
Monday, June 3, 13
Agenda
• Setup
• Introduction to PhoneGap
• JavaScript Best Practices
• Using Libraries
• Ajax
• Location & Maps
Monday, June 3, 13
Agenda
• Media
• Storage
• User Interface
• Icons & Splash Pages
• Performance Tips
Monday, June 3, 13
How We Will Progress
• Show a Few Slides
• Show Some Code
• LetYou Have a Turn
• Back to Slides
Monday, June 3, 13
The Apps
• Calculator
• Camera
• Compass
• Coffee + Coffee
• Touch Paint
Monday, June 3, 13
Setup Android
• Java SE 6u45 (not 7)
• Android Developer Tools
• Intellij IDEA 12 CE
Monday, June 3, 13
Build an Android App
Monday, June 3, 13
Setup PhoneGap
• Apache Ant 1.9.1
• PhoneGap 2.7.0
Monday, June 3, 13
Build a PhoneGap App
Monday, June 3, 13
Android Alphabet Soup
• ADB - Android Debug Bridge
• ADT - Android Developer Tools
• AVD Manager - AndroidVirtual Device
• DDMS - Dalvik Debug Monitor Server
• SDK Manager - Software Development Kit
Monday, June 3, 13
PhoneGap
Monday, June 3, 13
History
• Create by Nitobi in 2009 at an Apple Event
• Nitobi Acquired by Adobe
• Open Sourced as Apache Cordova
• PhoneGap is only one implementation
Monday, June 3, 13
Other Cordova
Implementations
• appMobi
• Convertigo
• Icenium (Telerik)
• ViziApps
• Worklight (IBM)
Monday, June 3, 13
Intro to PhoneGap
• What the heck is it?
• How it works?
Monday, June 3, 13
What the Heck is it?
• Think of it as a web site wrapped by an
mobile app
• Rather HTML or HTML5, more like HTML6
Monday, June 3, 13
How it Works?
• Most device APIs include an internal web
browser
• PhoneGap uses this internal web browser
as its app canvas
• It adds more features to the navigator via
software which bridges the gap between
the internal web and the device
Monday, June 3, 13
PhoneGap
• Current release is 2.7.0
• New release every few months
• Last few have been mainly bug fixes
• Recommend not upgrading your app to a
new version right away
Monday, June 3, 13
JavaScript Best
Practices
• Avoid sloppy JavaScript
• Avoid the Global Space
• Encapsulate Code into Objects
• Use Design Patterns
Monday, June 3, 13
Avoid Sloppy JavaScript
• JavaScript is a Harsh Mistress
• Always use ‘===’ & ‘!==’
• Code in JavaScript not C#, Java, Ruby, etc.
• Use JSLint or JSHint
Monday, June 3, 13
Avoid the Global Space
• Minimize Use of GlobalVariables
• Use Namespacing
• Use Anonymous/Immediate Functions
When Appropriate
Monday, June 3, 13
Use Design Patterns
• Singleton
• Chaining
•Revealing Module Structure
• + many more
Monday, June 3, 13
JavaScript Tips
• Functions
• Objects
• Events
Monday, June 3, 13
Functions
• Functions are first class type
• Like other types they can be passed and
assigned freely
• Anonymous functions are used frequently
Monday, June 3, 13
Objects
• Thing of JavaScript Objects like Key/Value
dictionary
• The Key can be anything when wrapped in
quotes
• TheValue can be any type including a
function
Monday, June 3, 13
Events
• Events allow for excellent separation of
concerns
• You can listen for system events or
• Trigger and respond to your own
• Many external libraries will communicate
via events
Monday, June 3, 13
Libraries
• jQuery - DOM manipulation / Ajax
• jQuery Mobile - Mobile UI
• zepto.js - lightweighter substitute for
jQuery
• underscore.js - utility belt library
• backbone.js - client side framework
Monday, June 3, 13
PGDCalculator
• Single Page App
• Uses jQuery Mobile for UI
• Hooks jQuery Mobile Events
Monday, June 3, 13
PGDCalculator
• HTML/jQuery Mobile UI
• My JQM Kernel to Dispatch Events
• JavaScript Logic
Monday, June 3, 13
Your Turn
• Open Project PCDCalculatorEx
• The UI is complete
• The Logic is complete
• Bind the two together, aka make the
buttons work
• Hint: Compare to the working version
Monday, June 3, 13
PGDCompass
• Even simpler than the Calculator
• Uses navigator.compass to supply rotation
value for a CSS3 object
• Only works on devices which have a
compass
Monday, June 3, 13
PGDCoffee
• Fairly Complicated App
• 5 Main Sections: Listings, Map, Settings,
Credits, and Details
• Use jQuery Mobile for UI
Monday, June 3, 13
Ajax
• We rely on jQuery for Ajax
• We also implement pull to refresh using
iScroll4 library and custom code
• CallsYP.com location services
Monday, June 3, 13
Location
• Use HTML5 location services
• Give user a way to use app with location
turned off
Monday, June 3, 13
Maps
• Most Web Mapping Kits will work
• PGDCoffee using Google MapsV3 for Maps
and reverse geocoding
• Reverse geocoding turns some part of an
address into a lat/long
Monday, June 3, 13
Media & Camera
• PhoneGap allows for the recording of
audio and video. Plus the taking of pictures
Monday, June 3, 13
PCDCamera
• Uses the device’s default camera
• Places picture into a canvas
• Dynamically sizes the canvas
Monday, June 3, 13
Your Turn
• Open Project PCDCamera
• Currently it can: take a pic
• Add functionality to the tweak button,
make it do anything you’d like
Monday, June 3, 13
Storage Options
• Memory
• Local Storage
• SQLite
Monday, June 3, 13
Links
• http://www.appmobi.com/
• http://www.convertigo.com/
• http://www-03.ibm.com/software/products/
us/en/worklight/
• http://www.viziapps.com/
Monday, June 3, 13
The Rock n Coder
• http://therockncoder.blogspot.com
• http://www.youtube.com/user/rockncoder
• https://github.com/Rockncoder
• http://www.slideshare.net/rockncoder
Monday, June 3, 13
What We Learned
• What PhoneGap is and isn’t
• Some JavaScript Best Practice
• How to go from web to app
Monday, June 3, 13

More Related Content

KEY
Phonegap for Engineers
PDF
Firefox OS - HTML5 for a truly world-wide-web
PPTX
Mobile native-hacks
PDF
Can we make es6 the baseline of the “modern web”? - BrazilJS 2105
PDF
Overboard.js - where are we going with with jsconfasia / devfestasia
KEY
Cross platform mobile apps
PDF
Erase and Rewind - Open Web Camp 2015
PDF
Everyones invited! Meet accesibility requirements with ColdFusion
Phonegap for Engineers
Firefox OS - HTML5 for a truly world-wide-web
Mobile native-hacks
Can we make es6 the baseline of the “modern web”? - BrazilJS 2105
Overboard.js - where are we going with with jsconfasia / devfestasia
Cross platform mobile apps
Erase and Rewind - Open Web Camp 2015
Everyones invited! Meet accesibility requirements with ColdFusion

What's hot (20)

KEY
Adobe and Modern Web Development
KEY
Skip the IDE with PhoneGap Build
PDF
The State of the Web - Helsinki meetup
PDF
Moore vs. May - everything is faster and better: we can fix that
PDF
The ES6 Conundrum - All Things Open 2015
PPTX
9 reasons why programmers should learn react native
PPTX
WordPress Rest API
PPTX
Desktop Apps in a Javascript World - Electron
PDF
Android development war stories
PPTX
Introduction to React native
PPTX
How to survive the JavaScript apocalypse
PDF
The image problem of the web and how to solve it…
PPTX
Functional webapplicaations using fsharp and suave
KEY
jQueryUI and HTML5 Video Play Nice
PDF
Universal apps lightning talk
PDF
Fixing web and JS gaps
PDF
Build the mobile web you want
PDF
Electron - Build desktop apps using javascript
PPTX
Question 4 amber
PPTX
React Native
Adobe and Modern Web Development
Skip the IDE with PhoneGap Build
The State of the Web - Helsinki meetup
Moore vs. May - everything is faster and better: we can fix that
The ES6 Conundrum - All Things Open 2015
9 reasons why programmers should learn react native
WordPress Rest API
Desktop Apps in a Javascript World - Electron
Android development war stories
Introduction to React native
How to survive the JavaScript apocalypse
The image problem of the web and how to solve it…
Functional webapplicaations using fsharp and suave
jQueryUI and HTML5 Video Play Nice
Universal apps lightning talk
Fixing web and JS gaps
Build the mobile web you want
Electron - Build desktop apps using javascript
Question 4 amber
React Native
Ad

Similar to PhoneGap in a Day (20)

PDF
PhoneGap in 60 Minutes or Less
PDF
Introduction to PhoneGap and PhoneGap Build
PDF
jQuery Mobile Jump Start
PDF
Native Javascript apps with PhoneGap by Martin de Keijzer
PDF
Building mobile apps with PhoneGap and Backbone
PDF
Native Javascript apps with PhoneGap
PDF
Mobile Web to Mobile Apps
PDF
Introduction to PhoneGap
PDF
jQuery Mobile, Backbone.js, and ASP.NET MVC
PDF
jQuery Mobile Deep Dive
KEY
KEY
Android development workshop
KEY
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
PPTX
Seattle bestpractices2010
KEY
DjangoSki
PDF
Building native mobile apps using web technologies
KEY
Philly ete-2011
KEY
Future of Mobile
PDF
Building Cross-Platform Mobile Apps
PPTX
Phone gap development, testing, and debugging
PhoneGap in 60 Minutes or Less
Introduction to PhoneGap and PhoneGap Build
jQuery Mobile Jump Start
Native Javascript apps with PhoneGap by Martin de Keijzer
Building mobile apps with PhoneGap and Backbone
Native Javascript apps with PhoneGap
Mobile Web to Mobile Apps
Introduction to PhoneGap
jQuery Mobile, Backbone.js, and ASP.NET MVC
jQuery Mobile Deep Dive
Android development workshop
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
Seattle bestpractices2010
DjangoSki
Building native mobile apps using web technologies
Philly ete-2011
Future of Mobile
Building Cross-Platform Mobile Apps
Phone gap development, testing, and debugging
Ad

More from Troy Miles (20)

PDF
Fast C++ Web Servers
PDF
Node Boot Camp
PDF
AWS Lambda Function with Kotlin
PDF
React Native One Day
PDF
React Native Evening
PDF
Intro to React
PDF
React Development with the MERN Stack
PDF
Angular Application Testing
PDF
ReactJS.NET
PDF
What is Angular version 4?
PDF
Angular Weekend
PDF
From MEAN to the MERN Stack
PDF
Functional Programming in JavaScript
PDF
Functional Programming in Clojure
PDF
MEAN Stack Warm-up
PDF
The JavaScript You Wished You Knew
PDF
Game Design and Development Workshop Day 1
PDF
Build a Game in 60 minutes
PDF
Quick & Dirty & MEAN
PDF
A Quick Intro to ReactiveX
Fast C++ Web Servers
Node Boot Camp
AWS Lambda Function with Kotlin
React Native One Day
React Native Evening
Intro to React
React Development with the MERN Stack
Angular Application Testing
ReactJS.NET
What is Angular version 4?
Angular Weekend
From MEAN to the MERN Stack
Functional Programming in JavaScript
Functional Programming in Clojure
MEAN Stack Warm-up
The JavaScript You Wished You Knew
Game Design and Development Workshop Day 1
Build a Game in 60 minutes
Quick & Dirty & MEAN
A Quick Intro to ReactiveX

Recently uploaded (20)

PPTX
Modernising the Digital Integration Hub
PPTX
Configure Apache Mutual Authentication
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
STKI Israel Market Study 2025 version august
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PPT
Geologic Time for studying geology for geologist
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
Zenith AI: Advanced Artificial Intelligence
DOCX
search engine optimization ppt fir known well about this
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PDF
Consumable AI The What, Why & How for Small Teams.pdf
Modernising the Digital Integration Hub
Configure Apache Mutual Authentication
Chapter 5: Probability Theory and Statistics
Benefits of Physical activity for teenagers.pptx
sbt 2.0: go big (Scala Days 2025 edition)
STKI Israel Market Study 2025 version august
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Convolutional neural network based encoder-decoder for efficient real-time ob...
Module 1.ppt Iot fundamentals and Architecture
OpenACC and Open Hackathons Monthly Highlights July 2025
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Geologic Time for studying geology for geologist
Flame analysis and combustion estimation using large language and vision assi...
Zenith AI: Advanced Artificial Intelligence
search engine optimization ppt fir known well about this
A review of recent deep learning applications in wood surface defect identifi...
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Microsoft Excel 365/2024 Beginner's training
Enhancing plagiarism detection using data pre-processing and machine learning...
Consumable AI The What, Why & How for Small Teams.pdf

PhoneGap in a Day

  • 1. PhoneGap in a Day with Troy Miles aka @therockncoder Monday, June 3, 13
  • 2. Free mobile tutorials with source code @ therockncoder.blogspot.com Monday, June 3, 13
  • 3. Want more? Follow me, new tutorials are announced on Twitter first: @therockncoder Monday, June 3, 13
  • 4. Source code for my tutorials hosted on GitHub @ https://github.com/Rockncoder Monday, June 3, 13
  • 5. Check out my videos: www.youtube.com/rockncoder Monday, June 3, 13
  • 6. Schedule • 8:00 Morning Session 1 • 10:00 Break • 10:15 Morning Session 2 • 12:00 Lunch • 12:45 Afternoon Session 1 Monday, June 3, 13
  • 7. Schedule • 2:45 Break • 3:00 Afternoon Session 2 • 4:45 Wrap Up Monday, June 3, 13
  • 8. Where Is? • Water • Restrooms Monday, June 3, 13
  • 9. Agenda • Setup • Introduction to PhoneGap • JavaScript Best Practices • Using Libraries • Ajax • Location & Maps Monday, June 3, 13
  • 10. Agenda • Media • Storage • User Interface • Icons & Splash Pages • Performance Tips Monday, June 3, 13
  • 11. How We Will Progress • Show a Few Slides • Show Some Code • LetYou Have a Turn • Back to Slides Monday, June 3, 13
  • 12. The Apps • Calculator • Camera • Compass • Coffee + Coffee • Touch Paint Monday, June 3, 13
  • 13. Setup Android • Java SE 6u45 (not 7) • Android Developer Tools • Intellij IDEA 12 CE Monday, June 3, 13
  • 14. Build an Android App Monday, June 3, 13
  • 15. Setup PhoneGap • Apache Ant 1.9.1 • PhoneGap 2.7.0 Monday, June 3, 13
  • 16. Build a PhoneGap App Monday, June 3, 13
  • 17. Android Alphabet Soup • ADB - Android Debug Bridge • ADT - Android Developer Tools • AVD Manager - AndroidVirtual Device • DDMS - Dalvik Debug Monitor Server • SDK Manager - Software Development Kit Monday, June 3, 13
  • 19. History • Create by Nitobi in 2009 at an Apple Event • Nitobi Acquired by Adobe • Open Sourced as Apache Cordova • PhoneGap is only one implementation Monday, June 3, 13
  • 20. Other Cordova Implementations • appMobi • Convertigo • Icenium (Telerik) • ViziApps • Worklight (IBM) Monday, June 3, 13
  • 21. Intro to PhoneGap • What the heck is it? • How it works? Monday, June 3, 13
  • 22. What the Heck is it? • Think of it as a web site wrapped by an mobile app • Rather HTML or HTML5, more like HTML6 Monday, June 3, 13
  • 23. How it Works? • Most device APIs include an internal web browser • PhoneGap uses this internal web browser as its app canvas • It adds more features to the navigator via software which bridges the gap between the internal web and the device Monday, June 3, 13
  • 24. PhoneGap • Current release is 2.7.0 • New release every few months • Last few have been mainly bug fixes • Recommend not upgrading your app to a new version right away Monday, June 3, 13
  • 25. JavaScript Best Practices • Avoid sloppy JavaScript • Avoid the Global Space • Encapsulate Code into Objects • Use Design Patterns Monday, June 3, 13
  • 26. Avoid Sloppy JavaScript • JavaScript is a Harsh Mistress • Always use ‘===’ & ‘!==’ • Code in JavaScript not C#, Java, Ruby, etc. • Use JSLint or JSHint Monday, June 3, 13
  • 27. Avoid the Global Space • Minimize Use of GlobalVariables • Use Namespacing • Use Anonymous/Immediate Functions When Appropriate Monday, June 3, 13
  • 28. Use Design Patterns • Singleton • Chaining •Revealing Module Structure • + many more Monday, June 3, 13
  • 29. JavaScript Tips • Functions • Objects • Events Monday, June 3, 13
  • 30. Functions • Functions are first class type • Like other types they can be passed and assigned freely • Anonymous functions are used frequently Monday, June 3, 13
  • 31. Objects • Thing of JavaScript Objects like Key/Value dictionary • The Key can be anything when wrapped in quotes • TheValue can be any type including a function Monday, June 3, 13
  • 32. Events • Events allow for excellent separation of concerns • You can listen for system events or • Trigger and respond to your own • Many external libraries will communicate via events Monday, June 3, 13
  • 33. Libraries • jQuery - DOM manipulation / Ajax • jQuery Mobile - Mobile UI • zepto.js - lightweighter substitute for jQuery • underscore.js - utility belt library • backbone.js - client side framework Monday, June 3, 13
  • 34. PGDCalculator • Single Page App • Uses jQuery Mobile for UI • Hooks jQuery Mobile Events Monday, June 3, 13
  • 35. PGDCalculator • HTML/jQuery Mobile UI • My JQM Kernel to Dispatch Events • JavaScript Logic Monday, June 3, 13
  • 36. Your Turn • Open Project PCDCalculatorEx • The UI is complete • The Logic is complete • Bind the two together, aka make the buttons work • Hint: Compare to the working version Monday, June 3, 13
  • 37. PGDCompass • Even simpler than the Calculator • Uses navigator.compass to supply rotation value for a CSS3 object • Only works on devices which have a compass Monday, June 3, 13
  • 38. PGDCoffee • Fairly Complicated App • 5 Main Sections: Listings, Map, Settings, Credits, and Details • Use jQuery Mobile for UI Monday, June 3, 13
  • 39. Ajax • We rely on jQuery for Ajax • We also implement pull to refresh using iScroll4 library and custom code • CallsYP.com location services Monday, June 3, 13
  • 40. Location • Use HTML5 location services • Give user a way to use app with location turned off Monday, June 3, 13
  • 41. Maps • Most Web Mapping Kits will work • PGDCoffee using Google MapsV3 for Maps and reverse geocoding • Reverse geocoding turns some part of an address into a lat/long Monday, June 3, 13
  • 42. Media & Camera • PhoneGap allows for the recording of audio and video. Plus the taking of pictures Monday, June 3, 13
  • 43. PCDCamera • Uses the device’s default camera • Places picture into a canvas • Dynamically sizes the canvas Monday, June 3, 13
  • 44. Your Turn • Open Project PCDCamera • Currently it can: take a pic • Add functionality to the tweak button, make it do anything you’d like Monday, June 3, 13
  • 45. Storage Options • Memory • Local Storage • SQLite Monday, June 3, 13
  • 46. Links • http://www.appmobi.com/ • http://www.convertigo.com/ • http://www-03.ibm.com/software/products/ us/en/worklight/ • http://www.viziapps.com/ Monday, June 3, 13
  • 47. The Rock n Coder • http://therockncoder.blogspot.com • http://www.youtube.com/user/rockncoder • https://github.com/Rockncoder • http://www.slideshare.net/rockncoder Monday, June 3, 13
  • 48. What We Learned • What PhoneGap is and isn’t • Some JavaScript Best Practice • How to go from web to app Monday, June 3, 13