Android App Development For Dummies - Michael Burton - E-Book

Android App Development For Dummies E-Book

Michael Burton

2,3
20,99 €

oder
Beschreibung

The updated edition of the bestselling guide to Android appdevelopment If you have ambitions to build an Android app, this hands-onguide gives you everything you need to dig into the developmentprocess and turn your great idea into a reality! In this newedition of Android App Development For Dummies, you'll findeasy-to-follow access to the latest programming techniques thattake advantage of the new features of the Android operating system.Plus, two programs are provided: a simple program to get youstarted and an intermediate program that uses more advanced aspectsof the Android platform. Android mobile devices currently account for nearly 80% ofmobile phone market share worldwide, making it the best platform toreach the widest possible audience. With the help of this friendlyguide, developers of all stripes will quickly find out how toinstall the tools they need, design a good user interface, graspthe design differences between phone and tablet applications,handle user input, avoid common pitfalls, and turn a "meh" app intoone that garners applause. * Create seriously cool apps for the latest Android smartphonesand tablets * Adapt your existing apps for use on an Android device * Start working with programs and tools to create Androidapps * Publish your apps to the Google Play Store Whether you're a new or veteran programmer, Android AppDevelopment For Dummies will have you up and running with theins and outs of the Android platform in no time.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 492

Bewertungen
2,3 (16 Bewertungen)
0
4
3
2
7



Android™ Application Development For Dummies®, 3rd Edition

Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030‐5774, www.wiley.com

Copyright © 2015 by John Wiley & Sons, Inc., Hoboken, New Jersey

Published simultaneously in Canada

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as ­permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior ­written ­permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748‐6011, fax (201) 748‐6008, or online at http://www.wiley.com/go/permissions.

Portions of this page are based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. Android is a trademark of Google, Inc. All other trademarks are the ­property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE 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. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE 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 the U.S. at 877‐762‐2974, outside the U.S. at 317‐572‐3993, or fax 317‐572‐4002. For technical support, please visit www.wiley.com/techsupport.

Wiley publishes in a variety of print and electronic formats and by print‐on‐demand. Some material included with standard print versions of this book may not be included in e‐books or in print‐on‐demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.

Library of Congress Control Number: 2014954664

ISBN: 978-1-119-01792-9

ISBN: 978-1-119-01793-6 (ePDF); ISBN: 978-1-119-01794-3 (ePub)

Android™ Application Development For Dummies®

Visit www.dummies.com/cheatsheet/androidappdevelopment to view this book's cheat sheet.

Table of Contents

Cover

Introduction

About This Book

Conventions Used in This Book

Foolish Assumptions

How This Book Is Organized

Icons Used in This Book

Beyond the Book

Part I: Getting Started with Your First Android Application

Chapter 1: Developing Spectacular Android Applications

Why Develop for Android?

Android Development Basics

Hardware Tools

Software Tools

Chapter 2: Prepping Your Development Headquarters

Developing the Android Developer Inside You

Assembling Your Toolkit

Tuning Up Your Hardware

Installing and Configuring Your Support Tools

Installing Android Studio

Installing Java 7

Adding SDK Packages

Navigating the Android SDK

Specifying Android Platforms

Using SDK Tools for Everyday Development

Part II: Building and Publishing Your First Application

Chapter 3: Your First Android Project

Starting a New Project in Android Studio

Responding to Errors

Setting Up an Emulator

Running the Hello Android App

Understanding Project Structure

Chapter 4: Creating the User Interface

Creating the Silent Mode Toggle Application

Laying Out the Application

Adding an Image to Your Application

Creating a Launcher Icon for the Application

Previewing the Application in the Visual Designer

Chapter 5: Coding Your Application

Understanding Activities and the Activity Lifecycle

Creating Your First Activity

Working with the Android Framework Classes

Installing Your Application

Material Design

Uh‐Oh! (Responding to Errors)

Thinking Beyond the Application Boundaries

Chapter 6: Understanding Android Resources

Understanding Resources

Working with Resources

Different Strokes for Different Folks: Using Resource Qualifier Directories

Chapter 7: Turning Your Application into an App Widget

Working with App Widgets in Android

Working with Intents and Pending Intents

Creating the App Widget

Placing Your Widget on the Home Screen

Chapter 8: Publishing Your App to the Google Play Store

Creating a Distributable File

Creating a Google Play Developer Profile

Pricing Your Application

Getting Screen Shots for Your Application

Uploading Your Application to the Google Play Store

Watching the Number of Installs Soar

Part III: Creating a Feature‐Rich Application

Chapter 9: Designing the Tasks Application

Reviewing the Basic Requirements

Creating the Application’s Screens

Chapter 10: Creating the Task Detail Page

Creating the TaskEditActivity

Linking the List View to the Edit View

Creating the TaskEditFragment

You Put the Fragment in the Activity and Shake It All Up

Updating the Styles

A Special Bonus

Chapter 11: Going a la Carte with Your Menu

Understanding Options and Context Menus

Creating Your First Menu

Creating a Long‐Press Action

Chapter 12: Handling User Input

Creating the User Input Interface

Getting Choosy with Dates and Times

Creating an Alert Dialog

Validating Input

Chapter 13: Getting Persistent with Data Storage

Finding Places to Put Data

Understanding How the SQLite ContentProvider Works

Creating Your Application’s SQLite Database

Using ContentProvider URIs

Dealing with CRUD

Implementing the Save Button

Implementing the List View

Reading Data into the Edit Page

Chapter 14: Reminding the User

Seeing Why You Need AlarmManager

Asking the User for Permission

Waking Up a Process with AlarmManager

Updating a Notification

Clearing a Notification

Rebooting Devices

Chapter 15: Working with Android Preferences

Understanding the Android Preferences Framework

Understanding the PreferenceFragment Class

Creating Your Preferences Screen

Working with the PreferenceFragment Class

Working with Preferences in Your Activities at Runtime

Part IV: Android Is More than Phones

Chapter 16: Developing for Tablets

Considering the Differences between Phones and Tablets

Tweaking the Tasks App for Tablets

Configuring a Tablet Emulator

Creating a New Product Flavor

Creating an AndroidManifest for Phones

Creating an AndroidManifest for Tablets

Making the TaskListAndEditorActivity for Tablets

Building the Tablet App

Adding the App Callbacks

One More Thing . . .

Chapter 17: Supporting Older Versions of Android

Understanding AppCompat

Updating the build File

Adding the Toolbar

Using the AppCompat Theme

Testing Your App

Working with Right‐to‐Left Languages

Fixing the Add Task Menu

Fixing the Window Options

Using Newer APIs

Using Android Lint

Chapter 18: Wearing the Tasks App

Preparing Your Development Environment

Creating a New Wear App

Publishing the Data from Your Phone

Running the App without Android Studio

Packaging the App

What’s Next?

Chapter 19: Look Ma, I’m on TV!

Understanding Guidelines for Building TV Apps

Building and Manifesting Changes

Adding the BrowseActivity

Creating the TV Browse Fragment

Creating the CardPresenter

Running Your App

Adding and Editing Items

Creating Backgrounds

Creating More Filters

Chapter 20: Moving beyond Google

Working around Google Features

Setting Up the Fire SDK

Setting Up Your Fire or Emulator

Publishing to Amazon Appstore for Android

Part V: The Part of Tens

Chapter 21: Ten Free Sample Applications and SDKs

Android Samples

The Google I/O App

K‐9 Mail

GitHub Android App

Facebook SDK for Android

Notepad Tutorial

U+2020

Lollipop Easter Egg

Android Bootstrap

The AOSP

Chapter 22: Ten Tools to Simplify Your Development Life

Android Lint

Android Systrace

RoboGuice and Dagger

Translator Toolkit

Hierarchy Viewer

UI/Application Exerciser Monkey

Git and GitHub

Picasso and OkHttp

Memory Analyzer Tool

Travis‐ci

About the Author

Cheat Sheet

Connect with Dummies

End User License Agreement

Guide

Cover

Table of Contents

Begin Reading

Pages

i

ii

1

2

3

4

5

6

7

8

9

10

11

12

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

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

419

420

Introduction

Welcome to Android Application Development For Dummies!

When Android was acquired by Google in 2005 (yes, Android was a start‐up company at one point), a lot of people didn’t have much interest in it because Google hadn’t yet entered the mobile space. Fast‐forward to a few years later, when Google announced its first Android phone: the G1. It was the start of something huge.

The G1 was the first publicly released Android device. It didn’t match the rich feature set of the iPhone at the time, but a lot of people believed in the platform. As soon as Donut (Android 1.6) was released, it was evident that Google was putting some effort into the product. Immediately after version 1.6 was released, talk of 2.0 was already on the horizon.

Today, we’re on version 5.0 of the Android platform, with no signs that things are slowing down. Without doubt, this is an exciting time in Android development.

About This Book

Android Application Development For Dummies is a beginner’s guide to developing Android applications. You don’t need any Android application development experience under your belt to get started.

The Android platform is a device‐independent platform, which means that you can develop applications for various devices. These devices include, but aren’t limited to phones, watches, tablets, cars, e‐book readers, netbooks, televisions, and GPS devices.

Finding out how to develop for the Android platform opens a large variety of development options for you. This book distills hundreds, if not thousands, of pages of Android documentation, tips, tricks, and tutorials into a short, digestible format that allows you to springboard into your future as an Android developer. This book isn’t a recipe book, but it gives you the basic knowledge to assemble various pieces of the Android framework to create interactive and compelling applications.

Conventions Used in This Book

Throughout the book, you use the Android framework classes, and you’ll create Java classes and XML files.

Code examples in this book appear in a monospace font so that they stand out from other text in the book. This means that the code you’ll see looks like this:

public class MainActivity

Java is a high‐level programming language that is case‐sensitive, so be sure to enter the text into the editor exactly as you see it in the book. The examples follow standard Java conventions so you can transition easily between the book examples and the example code provided by the Android Software Development Kit (SDK). All class names, for example, appear in PascalCase format.

All the URLs in the book appear in monospace font as well:

http://d.android.com

Foolish Assumptions

To begin programming with Android, you need a computer that runs one of the following operating systems:

Windows 2003, Vista, 7 or 8

Mac OS X 10.8.5 or later

Linux GNOME or KDE

You also need to download Android Studio (which is free) and the Java Development Kit (or JDK, which is also free), if you don’t already have them on your computer. Chapter 2 outlines the entire installation process for all the tools and frameworks.

Because Android applications are developed in the Java programming language, you need to understand the Java language. Android also uses XML quite heavily to define various resources inside the application, so you should understand XML too. You don’t have to be an expert in these languages, however.

You don’t need a physical Android device, because all the applications you build in this book will work on an emulator.

How This Book Is Organized

Android Application Development For Dummies has five parts, described in the following sections.

Part I: Getting Started with Your First Android Application

Part I introduces the tools and frameworks that you use to develop Android applications. It also introduces the various SDK components and shows you how they’re used in the Android ecosystem.

Part II: Building and Publishing Your First Android Application

Part II introduces you to building your first Android application: the Silent Mode Toggle application. After you build the initial application, you create an app widget for the application that you can place on the Home screen of an Android device. Then you publish your application to the Google Play Store.

Part III: Creating a Feature‐Rich Application

Part III takes your development skills up a notch by walking you through the construction of the Tasks application, which allows users to create various tasks with reminders. You implement an SQLite backed content provider in this multiscreen application. You also see how to use the Android status bar to create notifications that can help increase the usability of your application.

Part IV: Android Is More than Phones

Part IV takes the phone app you built in Part III and tweaks it to work on lots of other devices, including tablets, wearables, televisions, and the Amazon Fire.

Part V: The Part of Tens

Part V gives you a tour of sample applications that prove to be stellar launching pads for your Android apps, and useful Android libraries that can make your Android development career a lot easier.

Icons Used in This Book

This icon indicates a useful pointer that you shouldn’t skip.

This icon represents a friendly reminder about a vital point you should keep in mind while proceeding through a particular section of the chapter.

This icon signifies that the accompanying explanation may be informative but isn’t essential to understanding Android application development. Feel free to skip these snippets, if you like.

This icon alerts you to potential problems that you may encounter along the way. Read and remember these tidbits to avoid possible trouble.

This icon signifies that you’ll find additional relevant content at www.dummies.com/extras/androidappdevelopment.

Beyond the Book

In addition to the content in this book, you’ll find some extra content available at the www.dummies.com website:

The Cheat Sheet for this book at

www.dummies.com/cheatsheet/androidappdevelopment

Online articles covering additional topics at www.dummies.com/extras/androidappdevelopment

Here you’ll find the articles referred to on the page that introduces each part of the book. So, feel free to visit www.dummies.com/extras/androidappdevelopment. You’ll feel at home there . . . find coffee and donuts . . . okay, maybe not the coffee and donuts, but you can find cool supplementary information about things we couldn’t fit into the book, such as testing, GPS location tracking, voice control, and other fun topics.

Updates to this book, if any, at

www.dummies.com/extras/androidappdevelopment

Don’t want to type all the code in the book? You can download it from the book’s website at

www.dummies.com/go/androidappdevfd

.

If there are ever updates to this book, you can find them at

www.dummies.com/go/androidappdevfdupdates

.

Part I

Getting Started with Your First Android Application

Visit www.dummies.com for great Dummies content online.

In this part . . .

Part I introduces you to the Android platform and describes what makes a spectacular Android application. You explore various parts of the Android software development kit (SDK) and see how to use them in your applications. You install the tools and frameworks necessary to develop Android applications.

Chapter 1

Developing Spectacular Android Applications

In This Chapter

Seeing reasons to develop Android apps

Starting with the basics of Android development

Working with the hardware

Getting familiar with the software

Google rocks! Google acquired the Android platform in 2005 (see the sidebar “The roots of Android,” later in this chapter) to ensure that a mobile operating system (OS) can be created and maintained in an open platform. Google continues to pump time and resources into the Android project. Though devices have been available only since October 2008, over a billion Android devices have now been activated, and more than a million more are being added daily. In only a few years, Android has already made a huge impact.

It has never been easier for Android developers to make money by developing apps. Android users trust Google, and because your app resides in the Google Play Store, many users will be willing to trust your app, too.

Why Develop for Android?

The real question is, “Why not develop for Android?” If you want your app to be available to millions of users worldwide or if you want to publish apps as soon as you finish writing and testing them or if you like developing on an open platform, you have your answer. But in case you’re still undecided, continue reading.

Market share

As a developer, you have an opportunity to develop apps for a booming market. The number of Android devices in use is greater than the number of devices on all other mobile operating systems combined. The Google Play Store puts your app directly and easily into a user’s hands. Users don’t have to search the Internet to find an app to install — they can simply go to the preinstalled Google Play Store on their devices and have access to all your apps. Because the Google Play Store comes preinstalled on most Android devices (see for some exceptions), users typically search the Google Play Store for all their application needs. It isn’t unusual to see an app’s number of downloads soar in only a few days.

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!