1. Trang chủ
  2. » Công Nghệ Thông Tin

Professional Microsoft Smartphone Programming phần 1 doc

53 377 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 53
Dung lượng 725,36 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Here the notion func-of “sfunc-oftware platform” refers to an integrated computing environment that consists func-of an operating tem, the .NET runtime environment, a set of applications

Trang 2

Programming

Baijian Yang Pei Zheng Lionel M Ni

Trang 4

Programming

Trang 6

Programming

Baijian Yang Pei Zheng Lionel M Ni

Trang 7

Professional Microsoft ® Smartphone Programming

Copyright © 2007 by Wiley Publishing, Inc., Indianapolis, Indiana

Published simultaneously in Canada

01923, (978) 750-8400, fax (978) 646-8600 Requests to the Publisher for permission should be addressed to the LegalDepartment, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, oronline at http://www.wiley.com/go/permissions

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO TATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OFTHIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WAR-RANTIES OF FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BYSALES OR PROMOTIONAL MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUIT-ABLE FOR EVERY SITUATION THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOTENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES IF PROFESSIONALASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT.NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM THEFACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR APOTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHERENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS ITMAY MAKE FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAYHAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.For general information on our other products and services please contact our Customer Care Department within theUnited States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002

REPRESEN-Trademarks:Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are marks or registered trademarks of John Wiley & Sons, Inc and/or its affiliates, in the United States and other countries,and may not be used without written permission Microsoft is a registered trademark of Microsoft Corporation in theUnited States and/or other countries All other trademarks are the property of their respective owners Wiley Publishing,Inc., is not associated with any product or vendor mentioned in this book

Trang 8

trade-About the Authors

Baijian Yangis an assistant professor in the Computer Technology program at Ball State University

He became a Microsoft Certified Systems Engineer (MCSE) in 1998 and was one of the core softwaredesigners/developers for etang.com He received his Ph.D in Computer Science from Michigan StateUniversity in 2002 He is now engaged in research and development in the area of wireless networks anddistributed systems

Pei Zhengreceived his Ph.D in Computer Science from Michigan State University in 2003 He joinedMicrosoft as a software engineer in 2005 Before that he was an assistant professor of Computer Science

at Arcadia University, and a member of the technical staff at Bell Laboratories, Lucent Technologies His research interests include distributed systems, network simulation and emulation, and mobile computing

Lionel M Niis Chair Professor, Head of the Computer Science and Engineering Department, andDirector of the Digital Life Research Center at the Hong Kong University of Science and Technology Dr

Ni earned his Ph.D in electrical and computer engineering from Purdue University in 1980 He has beeninvolved in many projects related to wireless technologies, 2.5G/3G cellular phones, and embedded sys-

tems He is co-author of the book Interconnection Networks: An Engineering Approach (Morgan Kaufmann, 2002), and Smart Phone and Next Generation Mobile Computing (Morgan Kaufmann, 2006).

Trang 10

Quality Control Technicians

Laura AlbertBrian H Walls

Trang 11

To my wife, Chen Wen

Trang 12

Writing this book required a great deal of effort that went beyond our initial expectations We wouldfirst like to thank our family members, without whose support and encouragement we simply could notfinish this book

We also would like to thank the folks at Wiley Senior Acquisitions Editor Jim Minatel helped us shapeour proposal and provided us with professional help at every stage of the project Thank you very much,Jim, for believing in us and pushing to keep the project on the right track Development Editor JohnSleeva provided us with tons of valuable comments and suggestions, including insightful technical feed-back as well as general writing and formatting guidance Thank you very much, John, for your extensiveprofessional support and your dedication to keeping the project on a tight schedule Thanks, also, toProduction Editor Bill Barton and Copy Editor Luann Rouff for thoroughly checking and fixing thedetails of the book, including grammar, format, and layout Our appreciation also extends to other mem-bers of the Wiley team for your hardworking and consistent contributions to the book

Our special thanks go to Ya-Qin Zhang, the Vice President of Microsoft Corporation It was his visionand passion in mobile computing that initiated our book project Besides his inspirations to our work,Ya-Qin has also offered many helps to the book and directed our technical questions to the fellows atMicrosoft We would also like to thank Yong Rui at Microsoft Research for reviewing our work and pro-viding constructive professional opinions

Trang 14

Contents

Trang 15

Part II: Smartphone Application Development 37

Chapter 3: Developing Your First Smartphone Application 39

Trang 17

Contents

Trang 18

Contents

Privileged and Unprivileged Applications and Certificate Stores 310

Trang 19

Contents

Trang 21

Appendix A: New Features in NET Compact Framework 2.0 437

Appendix B: A Glance at the NET Compact Framework 2.0 Class Library 441

Appendix C: The Smartphone Bootstrapping Process 459

Trang 22

Computing has been continuously advancing for half a century In the early stages, mainframes andmini-computers drove the revolution, where they realized the computing transition from analog to digi-tal Then, in the 1980s and 90s, the personal computer (PC) became the dominant force, where its openframework enabled the widespread integration of desktop computing into people’s work and play Thethird computing wave came in the mid 1990s and continues to evolve today A key feature of this wave

is the integration of computing, communication, and storage technologies Cellular phones are at thecenter of this wave It is fair to say that a cellular phone is the most ubiquitous personal gadget everdevised: For the first time, a single device, less than the size of a wallet, captures the whole spectrum

of one’s daily activities

This book is about smartphones To be precise, smartphone is an overloaded word From a customer’s

point of view, a smartphone is a “smart” phone—an electronic handheld device that integrates the tionality of a mobile phone, personal digital assistant (PDA), or other information appliance A key fea-ture of a smartphone is that additional native applications can be installed on it For the content of this book, Smartphone is the software platform running on the physical smartphones Here the notion

func-of “sfunc-oftware platform” refers to an integrated computing environment that consists func-of an operating tem, the NET runtime environment, a set of applications, and related application development tools.Microsoft began its foray into the mobile software platform about a decade ago, and has recently picked

sys-up the pace significantly The Microsoft NET Compact Framework and Microsoft Smartphone platformhave demonstrated strong potential in commanding a significant share of the mobile OS market In 2005,Windows Mobile held the number one worldwide volume share of the PDA market, had 40 device makers and 68 mobile operators in 48 countries, 640,000 developers worldwide, and more than 18,000applications Microsoft’s strategy with Windows Mobile is to make it a powerful and open platform;emphasize the integration between devices, PCs, servers, and the Web; and build a rich ecosystem thatinspires innovation

The book is unique in several ways First, although a few books address the Microsoft NET CompactFramework or Windows Mobile, they discuss these two topics in isolation This is the first book dedi-cated to Smartphone software development with sufficient programming details Second, this book tar-gets a wide audience On the one hand, it covers the basics of Windows Mobile and the NET CompactFramework, so it is a good textbook for students in school On the other hand, it has an entire part onadvanced topics, which is valuable to both veteran practitioners and experienced developers Last butnot least, it offers a good mix of both the authors’ experience and expertise Professor Yang and Dr.Zheng are two of the most passionate young researchers in the field, with a lot of hands-on experience.Professor Ni is a veteran in wireless technologies, 2.5G/3G cellular phones, and embedded systems Thiscombination of energy, hands-on experience, and long-term vision ensure that the book is of highestquality

I continue to be pleasantly surprised by how powerful smartphones become I call a smartphone a

C3 device, because it seamlessly combines the functions of communication (voice call, e-mail, and IM),

computing (entertainment and location-based services), and control (a universal remote control and

Trang 24

The smartphone segment of the worldwide mobile wireless industry is growing rapidly, largely due tothe strong demand for converged mobile devices from enterprises and consumers ABI Research predictsthat smartphone sales worldwide will reach 150 million by 2008 Many enterprises are consideringdeploying mobile applications, and many consumers want a converged device for both communicationand computing Both of these markets have created enormous opportunities for mobile applicationdesign and development, and the migration of desktop applications to mobile devices, with enablingand powerful programming tools on a variety of mobile software platforms

Microsoft began its quest for mobile markets over a decade ago but was not able to draw much of theattention until recently, partly due to its powerful developing tools for its mobile operating system TheMicrosoft NET Compact Framework and Microsoft Smartphone platform have demonstrated a strongpotential to realize a significant share of the mobile operating system market In 2005, sales of WindowsMobile–powered devices grew by 40 percent As a result, both the end-user community and the devel-oper community of Microsoft Smartphone have grown significantly The upcoming Windows Mobile 6.0,which is estimated to be shipped in 2007, will surely further boost Microsoft Smartphone software development

Although you can find some books that address the Microsoft NET Compact Framework or WindowsMobile, they tend to focus on Pocket PC devices or a general discussion of NET Compact Frameworkprogramming Moreover, none of them is dedicated to Microsoft Smartphone software developmentwith sufficient programming details The MSDN website and some online resources do provide in-deptharticles about mobile programming, but the documents are not systematically organized, making it diffi-cult for developers to efficiently use them It was our intention to provide the first comprehensive bookdedicated to Smartphone programming

The major goals of this book are as follows:

❑ To help you understand the software design guidelines for Smartphone devices

❑ To demonstrate how to develop, debug, and deploy Smartphone applications with MicrosoftVisual Studio 2005 in C#

❑ To discuss security and performance issues in Smartphone programming

❑ To provide you with essential programming skills that you can apply when the next version ofSmartphone, the NET Compact Framework, and Visual Studio are released

Who This Book Is For

As a detailed reference to Microsoft Smartphone programming with the Microsoft NET CompactFramework, the core audience for this book includes software architects and developers working in thearea of mobile application development with intermediate programming skills in C/C++ or C#, and pro-fessionals seeking a thorough overview of the Microsoft Smartphone software development platform

Trang 25

Students (assuming some C/C++ or C# programming experience) who would like to gain some ence with Microsoft Windows Mobile programming will also find this book valuable Experienceddevelopers familiar with the NET framework and C# can skim or skip the first three introductory chap-ters and jump to Chapter 4

experi-What This Book Covers

This book is a comprehensive guide to Microsoft Smartphone programming with the Microsoft NETCompact Framework It provides in-depth coverage of key architectural concepts, application designguidelines, and programming techniques for Microsoft Smartphone software developers, and includesextensive hands-on examples and code listings Visual Studio 2005 and the NET Compact Framework2.0 are used as the underlying programming environment (although a number of chapters touch onissues in the NET Compact Framework 1.0, Smartphone 2002, and Smartphone 2003

How This Book Is Str uctured

The topics covered in the book can be divided into three categories:

Part I, “Smartphone and NET,”presents an overview of the Microsoft Smartphone platform from asoftware developer’s perspective It also covers the NET Compact Framework, the Smartphone pro-gramming environment, and a quick get-started guide to Microsoft Smartphone programming

Part II, “Smartphone Application Development,”discusses Microsoft Smartphone–related applicationdesign and programming in the domains of the NET Compact Framework (managed code) Each topicstarts out with a brief overview of key concepts and tasks covered in the chapter, followed by a detaileddiscussion of the programming framework and classes available in Windows Mobile and the

Smartphone SDK

Part III, “Advanced Topics,”covers application development topics such as security, globalization andlocalization, graphics, and performance considerations

What You Need to Use This Book

Because this book focuses heavily on Smartphone programming with Visual Studio 2005, it is expectedthat readers have this tool installed on a desktop computer running Windows XP or Windows Vista Inaddition, it would be better if a Windows Smartphone device were available for developing and testing.However, if that is not available, readers can simply use the Smartphone Emulator that comes withVisual Studio 2005

Conventions

To help you get the most from the text and keep track of what’s happening, we’ve used a number of ventions throughout the book

Trang 26

Introduction

Tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.

As for styles in the text:

We highlight new terms and important words when we introduce them.

❑ We show keyboard strokes like this: Ctrl+A

❑ We show filenames, URLs, and code-related terms within the text like so: persistence.properties

❑ We present code in two different ways:

In code examples we highlight new and important code with a gray background

The gray highlighting is not used for code that’s less important in the presentcontext, or has been shown before

Source Code

As you work through the examples in this book, you may choose either to type in all the code manually

or to use the source code files that accompany the book All of the source code used in this book is able for download at www.wrox.com Once at the site, simply locate the book’s title (either by using theSearch box or by using one of the title lists) and click the Download Code link on the book’s details page

avail-to obtain all the source code for the book

Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-0-471-76293-5.

Once you download the code, just decompress it with your favorite compression tool Alternately, youcan go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspxtosee the code available for this book and all other Wrox books

Errata

We make every effort to ensure that there are no errors in the text or in the code However, no one is fect, and mistakes do occur If you find an error in one of our books, such as a spelling mistake or faultypiece of code, we would be very grateful for your feedback By sending in errata you may save anotherreader hours of frustration, and at the same time you will be helping us provide even higher qualityinformation

per-To find the errata page for this book, go to www.wrox.comand locate the title using the Search box or one

of the title lists Then, on the book’s details page, click the Book Errata link On this page you can view all

Boxes like this one hold important, not-to-be forgotten information that is directly relevant to the surrounding text.

Ngày đăng: 12/08/2014, 23:23

TỪ KHÓA LIÊN QUAN