1. Trang chủ
  2. » Giáo án - Bài giảng

phonegap mobile application development cookbook

320 599 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 320
Dung lượng 23,77 MB

Nội dung

www.it-ebooks.info PhoneGap Mobile Application Development Cookbook Over 40 recipes to create mobile applications using the PhoneGap API with examples and clear instructions Matt Gifford BIRMINGHAM - MUMBAI www.it-ebooks.info PhoneGap Mobile Application Development Cookbook Copyright © 2012 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: October 2012 Production Reference: 1151012 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-84951-858-1 www.packtpub.com Cover Image by Neha Rajappan (neha.rajappan1@gmail.com) www.it-ebooks.info Credits Author Matt Gifford Reviewers Raymond Camden Shaun Dunne Andrey Rebrov Acquisition Editor Usha Iyer Lead Technical Editor Unnati Shah Technical Editor Jalasha D'costa Project Coordinator Joel Goveya Proofreader Mario Cecere Indexer Hemangini Bari Graphics Valentina D'silva Production Coordinator Manu Joseph Cover Work Manu Joseph www.it-ebooks.info www.it-ebooks.info Foreword In the summer of 2007, Steve Jobs changed the world by releasing the iPhone and boldly declared the future was web-based applications. A short year later, the story changed, but the vision remained. At this time I was working as "acting CTO" for a very small web consultancy called Nitobi (we gave ourselves joke titles and mine was actually SPACELORD!1!!). The iPhone SDK, not yet called iOS SDK, was just released and a few of my colleagues found themselves at Adobe in San Francisco for the iPhone Dev Camp. They arrived with the ambiguous idea to discover if it actually was possible to realize web technology for app development. Rob Ellis, Brock Whitten, and Eric Osterly succeeded in bridging the UIWebView to make native calls, and the rst implementation of PhoneGap was born. A very short time later, Joe Bowser built an Android implementation. Dave Johnson, Nitobi's "real CTO", followed quickly with the BlackBerry implementation. Herein, PhoneGap got real. And then, less than a year from the rst commits, in the spring of 2009, I found myself giving one of the rst PhoneGap presentations at the rst JSConf, and despite me being terribly scared, people loved it. Perhaps developers only loved the meme and the expletive-heavy presentation style I relied on to mask my terror. But perhaps developers really loved being treated like cohorts in a bigger plan, and respected by a technology instead of being locked into another proprietary ghetto. We were, and still are, web developers with a strong bias for composing our own stacks from open source code. We want to be writing web apps, with technology of our choosing, and not paying for the right to do so. We didn't want a PhoneGap to exist, and so it is the goal of the project to see this thing through to obsolescence. This work continues under the stewardship of the Apache Software foundation under the name Apache Cordova. Dening our vision, and planning our execution to our end has been my primary role in the project since inception, in addition to meme, and expletive, heavy presentations. Today PhoneGap is a robust, mature, well-tested, and a regularly released software project. There are 30 full-time core committers with us at Apache from a range of sponsoring organizations, and many hundreds more pitching in every day. All major operating systems are supported, our docs are comprehensive, the CLI tooling makes common mobile dev workows trivial, the APIs cover all the common device capabilities, and we have a well documented plugin interface for extending beyond the browser. www.it-ebooks.info Matt Gifford has been a long time supporter and hacker of PhoneGap, and his book brings his hard-won experience back to you. In this text you will nd the specic areas you need to tackle, be it accessing the device sensors (such as geolocation) or the system data (such as the lesystem or perhaps the phone contacts). You will have a handy reference for dealing with rich media such as images, audio, and video. Writing HTML, CSS, and JavaScript can be daunting and Matt has thankfully given you two great options to get started with, they are, XUI and jQuery Mobile. Finally, when you need to take your app beyond default PhoneGap and expose native capability you can learn all about the PhoneGap Plugin API. Building applications for mobile devices is hard work but using PhoneGap makes that job a whole lot easier, and more portable to the inevitable future web. Matt's book will help you get there now. Have fun, and if you need any help at all, don't hesitate to nd me (or Matt) online. Brian Leroux, Senior Product Manager, PhoneGap Lead and SPACELORD!1!!, Adobe Systems Ltd www.it-ebooks.info About the Author Matt Gifford is an RIA developer from Cambridge, England, who specializes in ColdFusion, web application, and mobile development. With over ten years industry experience across various sectors, Matt is owner of Monkeh Works Ltd. (www.monkehworks.com). A regular presenter at national and international conferences, he also contributes articles and tutorials in leading international industry magazines, as well as publishing on his blog ( www.mattgifford.co.uk). As an Adobe Community Professional for ColdFusion, Matt is an advocate of community resources and industry-wide knowledge sharing, with a focus on encouraging the next generation of industry professionals. Matt is the author of Object-Oriented Programming in ColdFusion and numerous open source applications, including the popular monkehTweets twitter API wrapper. First and foremost, my thanks go to all the talented PhoneGap developers for their innovative and inspiring project. Without you this book would be a ream of blank pages. www.it-ebooks.info About the Reviewers Raymond Camden is a senior developer evangelist for Adobe. His work focuses on web standards, mobile development, and ColdFusion. He's a published author and presents at conferences and user groups on a variety of topics. Raymond can be reached at his blog (www.raymondcamden.com), @cfjedimaster on Twitter, or via e-mail at raymondcamden@gmail.com. Shaun Dunne is a developer working for SapientNitro in London, UK and has been coding since 2008 with a passion for JavaScript and all the frontend goodness. Working for a large agency, over the past few years, Shaun has had the chance to use various web technologies to build large scale applications and found a passion for getting other people excited about the web. Shaun has been hacking the mobile web for a couple of years, trying and testing all the tools available, and sharing his discoveries where he can to ensure that others are aware of what is available to use and in what situation. When he's not working or spending some family time with his kids, he can usually be found on the web, tinkering, blogging, and building things. He's currently working on his own book, a self-published title about SASS and Friends called UberCSS due to be released in the Winter of 2012. www.it-ebooks.info Andrey Rebrov started as a software developer in Magenta Technology – a big British software company specializing in enterprise java solutions and has worked with them for more than three years. Andrey now works as agile engineering coach in ScrumTrek, Russia. As an engineering coach, he helps teams with learning and adopting XP practice, as TDD. A big part of his job is building the Russian Software Craftsmanship Community. At work, he also uses innovation and agile games and at the moment, works on innovation games popularization in Russia and Russian communities. Andrey has even worked on PhoneGap: Beginner's Guide. I would like to thank Joel Goveya for his help and patience during review. I would like to thank my parents for providing me with the opportunity to be where I am. Without them, none of this would even be possible. You have always been my biggest support and I appreciate that. And last but not the least, thanks to my wife, Tatyana, who always gives me strength and hope. www.it-ebooks.info [...]... using the PhoneGap JavaScript API, and your HTML applications instantly become detailed apps with incredibly powerful features www.it-ebooks.info Preface PhoneGap Mobile Application Development Cookbook will demonstrate a variety of examples to help you enhance your applications using the PhoneGap API This book contains everything you need to get started with, to experience mobile application development. .. Chapter 7, User Interface Development with jQuery Mobile, guides the user through the processes of using the jQuery Mobile framework to create a simple mobile application, including page transitions and "near-native" user interface elements Chapter 8, Extending PhoneGap with Plugins, describes how to extend the PhoneGap API and available methods by creating custom plugins Chapter 9, Development Tools and... your mobile application development environment and the tools available to help streamline your workflow What you need for this book You will need a computer, a web browser, and a code editor of your choice Some code editors include features and functions that have been designed to assist you specifically with PhoneGap mobile application development, and some of these are described in Chapter 9, Development. .. XUI 161 Chapter 7: User Interface Development with jQuery Mobile 193 Chapter 8: Extending PhoneGap with Plugins 217 Chapter 9: Development Tools and Testing 239 Introduction 111 Listing all available contacts 111 Displaying contact information for a specific individual 117 Creating and saving a new contact 122 Introduction 131 Pausing your application 131 Resuming your application 134 Displaying the status... development using the PhoneGap library through the step-by-step examples and recipes found within PhoneGap or Cordova Throughout this book you may find that the terms Cordova and PhoneGap are used interchangeably Both refer to exactly the same open source platform and library to enable you to create native mobile applications built using HTML, JavaScript, and CSS In 2011, the PhoneGap codebase moved... Dreamweaver CS5.5 and CS6, for example, include support for PhoneGap and the PhoneGap Build service Ultimately, you can develop mobile applications using the Cordova /PhoneGap library for free It costs nothing to download the library, and you can write HTML, CSS, and JavaScript using any text editor you have available or are comfortable with Even running the applications on a device emulator won't cost you anything,... www.it-ebooks.info Preface Who this book is for This book is for anyone with prior exposure to HTML, CSS, and JavaScript development, regardless of skill set, and for anyone looking to enter the world of mobile application development, or those wishing to enhance their existing HTML applications with mobile- specific features and functions Conventions In this book, you will find a number of styles of text that... with remote data and AJAX requests 183 Animating an element 187 Introduction 193 Creating a jQuery Mobile layout 193 Persisting data between jQuery Mobile pages 203 Using jQuery Mobile ThemeRoller 210 Introduction 217 Extending your Cordova application with a native plugin 218 Extending your Cordova iOS application with a native plugin 226 The plugin repository 236 Introduction 239 Downloading Cordova... any impact if at all they may have on developers, project contributors, and the PhoneGap community in general http:/ /phonegap. com/2012/03/19 /phonegap- cordova-and-what%E2%80%99sin-a-name/ Help is at hand While a lot of information is included in this book to cover the various methods and functions available through the PhoneGap library, there may be features that aren't covered here that you need answers... for a second explanation and some extra clarity Second, the PhoneGap Google group forum, available at groups.google.com/group/ phonegap, provides an open discussion list for PhoneGap developers, contributors, and users covering a wide variety of topics Here you can post questions and see what issues other community members may be facing The PhoneGap community is passionate, helpful and considerate, . www.it-ebooks.info PhoneGap Mobile Application Development Cookbook Over 40 recipes to create mobile applications using the PhoneGap API with examples and clear instructions Matt. and clear instructions Matt Gifford BIRMINGHAM - MUMBAI www.it-ebooks.info PhoneGap Mobile Application Development Cookbook Copyright © 2012 Packt Publishing All rights reserved. No part of. jQuery Mobile. Finally, when you need to take your app beyond default PhoneGap and expose native capability you can learn all about the PhoneGap Plugin API. Building applications for mobile

Ngày đăng: 28/04/2014, 16:12