0

Java Programming for Android Developers For Dummies

eBook

Erschienen am 19.10.2016, 2. Auflage 2016
22,99 €
(inkl. MwSt.)

Download

E-Book Download
Bibliografische Daten
ISBN/EAN: 9781119301097
Sprache: Englisch
Umfang: 464 S., 8.07 MB
E-Book
Format: EPUB
DRM: Adobe DRM

Beschreibung

Develop the next killer Android App using Java programming!

Android is everywhere! It runs more than half the smartphones in the U.S.and Java makes it go. If you want to cash in on its popularity by learning to build Android apps with Java, all the easy-to-follow guidance you need to get started is at your fingertips. Inside, you'll learn the basics of Java and grasp how it works with Android; then, you'll go on to create your first real, working application. How cool is that?

The demand for Android apps isn't showing any signs of slowing, but if you're a mobile developer who wants to get in on the action, it's vital that you get the necessary Java background to be a success. With the help ofJava Programming for Android Developers For Dummies, you'll quickly and painlessly discover the ins and outs of using Java to create groundbreaking Android appsno prior knowledge or experience required!Get the know-how to create an Android program from the ground upMake sense of basic Java development concepts and techniquesDevelop the skills to handle programming challengesFind out how to debug your app

Don't sit back and watch other developers release apps that bring in the bucks! Everything you need to create that next killer Android app is just a page away!

Autorenportrait

Barry Burd, PhD, is a professor in the Department of Mathematics and Computer Science at Drew University in Madison, New Jersey. He has lectured at conferences in the United States, Europe, Australia, and Asia. He hosts podcasts and videos about software and other technology topics. He is the author of many articles and books, includingJava For Dummies.

Inhalt

Introduction 1

How to Use This Book 1

Conventions Used in This Book 2

What You Dont Have to Read 2

Foolish Assumptions 3

How This Book Is Organized 4

Part 1: Getting Started with Java Programming for Android Developers 4

Part 2: Writing Your Own Java Programs 5

Part 3: Working with the Big Picture: Object-Oriented Programming 5

Part 4: Powering Android with Java Code 5

Part 5: The Part of Tens 5

More on the web! 6

Icons Used in This Book 6

Beyond the Book 7

Where to Go from Here 7

Part 1: Getting Started with Java Programming For Android Developers 9

Chapter 1: All about Java and Android 11

The Consumer Perspective 12

The Many Faces of Android 13

The Developer Perspective 15

Java 15

Xml 18

Linux 19

From Development to Execution with Java 20

What is a compiler? 20

What is a virtual machine? 24

Java, Android, and Horticulture 26

Chapter 2: Getting the Tools That You Need 27

The Stuff You Need 28

If You Dont Like to Read the Instructions . 29

Getting This Books Sample Programs 32

Setting Up Java 33

Setting Up Android Studio and the Android SDK 37

Launching the Android Studio IDE 38

Opening One of This Books Sample Programs 40

Using Android Studio 42

Starting up 42

The main window 43

Things You Might Eventually Have to Do 48

Installing new versions (and older versions) of Android 49

Creating an Android virtual device 50

Chapter 3: Creating and Running an Android App 55

Creating Your First App 56

First things first 57

Launching your first app 61

If the Emulator Doesnt Behave 63

Running third-party emulators 64

Testing apps on a physical device 65

The Project Tool Window 68

The app/manifests branch 68

The app/java branch 69

The app/res branches 69

The Gradle scripts branch 70

Dragging, Dropping, and Otherwise Tweaking an App 70

Creating the look 71

Coding the behavior 83

What All That Java Code Does 88

Finding the EditText and TextView components 88

Responding to a button click 90

The rest of the code 91

Going Pro 93

Part 2: Writing Your Own Java Programs 95

Chapter 4: An Ode to Code 97

Hello, Android! 97

The Java Class 99

The names of classes 103

Why Java Methods Are Like Meals at a Restaurant 105

What does Moms Restaurant have to do with Java? 106

Method declaration 106

Method call 108

Method parameters 108

The chicken or the egg 109

How many parameters? 109

Method declarations and method calls in an Android program 111

Punctuating Your Code 116

Comments are your friends 119

Whats Barrys excuse? 122

All About Android Activities 123

Extending a class 124

Overriding methods 124

An activitys workhorse methods 125

Chapter 5: Javas Building Blocks 129

Info Is As Info Does 130

Variable names 133

Type names 133

Assignments and initializations 134

Expressions and literals 136

How to string characters together 139

Javas primitive types 140

Things You Can Do with Types 142

Add letters to numbers (Huh?) 144

Javas exotic assignment operators 146

True bit 147

Java isnt like a game of horseshoes 148

Use Javas logical operators 150

Parenthetically speaking 155

Chapter 6: Working with Java Types 157

Working with Strings 157

Going from primitive types to strings 158

Going from strings to primitive types 159

Getting input from the user 160

Practice Safe Typing 163

Widening is good; narrowing is bad 165

Incompatible types 166

Using a hammer to bang a peg into a hole 167

Chapter 7: Though These Be Methods, Yet There Is Madness int 169

Minding Your Types When You Call a Method 170

Method parameters and Java types 173

If at first you dont succeed 174

Return types 174

The great void 175

Displaying numbers 176

Primitive Types and Pass-by Value 177

Whats a developer to do? 181

A final word 183

Chapter 8: What Java Does (and When) 187

Making Decisions 187

Java if statements 189

Choosing among many alternatives 191

Some formalities concerning Java switch statements 198

Repeating Instructions Over and Over Again 199

Check, and then repeat 200

Repeat, and then check 207

Count, count, count 211

Whats Next? 214

Part 3: Working with the Big Picture: Object-oriented Programming 215

Chapter 9: Why Object-Oriented Programming Is Like Selling Cheese 217

Classes and Objects 219

What is a class, really? 220

What is an object? 222

Creating objects 223

Reusing names 227

Calling a constructor 230

More About Classes and Objects (Adding Methods to the Mix) 232

Constructors with parameters 235

The default constructor 239

This is it! 240

Giving an object more responsibility 242

Members of a class 245

Reference types 246

Pass by reference 247

Javas Modifiers 251

Public classes and default-access classes 251

Access for fields and methods 253

Using getters and setters 257

What does static mean? 260

To dot, or not 263

A bad example 264

Whats Next? 265

Chapter 10: Saving Time and Money: Reusing Existing Code 267

The Last Word on Employees Or Is It? 268

Extending a class 269

Overriding methods 272

Javas super keyword 278

Java annotations 279

More about Javas Modifiers 281

Keeping Things Simple 285

Using an interface 286

Some Observations about Androids Classes 291

Javas super keyword, revisited 292

Casting, again 293

Part 4: Powering Android with Java Code 295

Chapter 11: The Inside Story 297

A Button-Click Example 297

This is a callback 302

Android string resources (A slight detour) 302

Introducing Inner Classes 307

No Publicity, Please! 309

Lambda Expressions 313

Chapter 12: Dealing with a Bunch of Things at a Time 317

Creating a Collection Class 318

More casting 320

Java generics 321

Javas wrapper classes 325

Stepping Through a Collection 326

Using an iterator 326

The enhanced for statement 328

A cautionary tale 329

Functional programming techniques 331

Javas Many Collection Classes 332

Arrays 333

String resource arrays 336

Javas varargs 337

Using Collections in an Android App 340

The listener 343

The adapter 343

Chapter 13: An Android Social Media App 345

The Twitter Apps Files 346

The Twitter4J API jar file 346

The manifest file 348

The main activitys layout file 349

How to Talk to the Twitter Server 352

Using OAuth 353

Making a ConfigurationBuilder 353

Getting OAuth keys and tokens 355

The Applications Main Activity 357

The onCreate method 362

The button listener methods 363

The trouble with threads 363

Understanding Androids AsyncTask 366

My Twitter apps AsyncTask classes 368

Cutting to the chase, at last 370

Javas Exceptions 372

Catch clauses 374

A finally clause 375

Passing the buck 376

Chapter 14: Hungry Burds: A Simple Android Game 381

Introducing the Hungry Burds Game 382

The Main Activity 385

The code, all the code, and nothing but the code 388

Measuring the display 392

Constructing a Burd 395

Android animation 398

Creating menus 400

Shared preferences 403

Informing the user 404

Its Been Fun 405

Part 5: the Part of Tens 407

Chapter 15: Ten Ways to Avoid Mistakes 409

Putting Capital Letters Where They Belong 409

Breaking Out of a switch Statement 410

Comparing Values with a Double Equal Sign 410

Adding Listeners to Handle Events 411

Defining the Required Constructors 411

Fixing Nonstatic References 412

Staying within Bounds in an Array 412

Anticipating Null Pointers 412

Using Permissions 414

The Activity Not Found 414

Chapter 16: Ten Websites for Developers 415

This Books Websites 415

The Horses Mouth 416

Finding News and Reviews 416

Index 417

Informationen zu E-Books

„E-Book“ steht für digitales Buch. Um diese Art von Büchern lesen zu können wird entweder eine spezielle Software für Computer, Tablets und Smartphones oder ein E-Book Reader benötigt. Da viele verschiedene Formate (Dateien) für E-Books existieren, gilt es dabei, einiges zu beachten.
Von uns werden digitale Bücher in drei Formaten ausgeliefert. Die Formate sind EPUB mit DRM (Digital Rights Management), EPUB ohne DRM und PDF. Bei den Formaten PDF und EPUB ohne DRM müssen Sie lediglich prüfen, ob Ihr E-Book Reader kompatibel ist. Wenn ein Format mit DRM genutzt wird, besteht zusätzlich die Notwendigkeit, dass Sie einen kostenlosen Adobe® Digital Editions Account besitzen. Wenn Sie ein E-Book, das Adobe® Digital Editions benötigt herunterladen, erhalten Sie eine ASCM-Datei, die zu Digital Editions hinzugefügt und mit Ihrem Account verknüpft werden muss. Einige E-Book Reader (zum Beispiel PocketBook Touch) unterstützen auch das direkte Eingeben der Login-Daten des Adobe Accounts – somit können diese ASCM-Dateien direkt auf das betreffende Gerät kopiert werden.
Da E-Books nur für eine begrenzte Zeit – in der Regel 6 Monate – herunterladbar sind, sollten Sie stets eine Sicherheitskopie auf einem Dauerspeicher (Festplatte, USB-Stick oder CD) vorsehen. Auch ist die Menge der Downloads auf maximal 5 begrenzt.