Introduction

Welcome to the third edition of Android Recipes!

If you are reading this book, you probably don’t need to be told of the immense opportunity that mobile devices represent for software developers and users. In recent years, Android has become one of the top mobile platforms for device users. This means that you, as a developer, must know how to harness Android so you can stay connected to this market and the potential that it offers. But any new platform brings with it uncertainty about best practices and solutions to common needs and problems.

What we aim to do with Android Recipes is give you the tools to write applications for the Android platform through direct examples targeted at the specific problems you are trying to solve. This book is not a deep dive into the Android SDK, NDK, or any of the other tools. We don’t weigh you down with all the details and theory behind the curtain. That’s not to say that those details aren’t interesting or important. You should take the time to learn them, as they may save you from making future mistakes. However, more often than not, they are simply a distraction when you are just looking for a solution to an immediate problem.

This book is not meant to teach you Java programming or even the building blocks of an Android application. You won’t find many basic recipes in this book (such as how to display text with TextView, for instance), as we feel these are tasks easily remembered once learned. Instead, we set out to address tasks that developers, once comfortable with Android, need to do often but find too complex to accomplish with a few lines of code.

Treat Android Recipes as a reference to consult, a resource-filled cookbook that you can always open to find the pragmatic advice you need to get the job done quickly and well.

What Will You Find in the Book?

Although this book is not a beginner’s guide to Android, Chapter 1 offers an overview of those Android fundamentals that are necessary for understanding the rest of the book’s content. Specifically, it shows you how to install the Android SDK and get up and running with the library code, including the Android Support Library and Google Play Services.

Performance matters if you want your applications to succeed. Most of the time, this isn’t a problem because the Android runtime engines get progressively better at compiling bytecode into the device’s native code. However, you might need to leverage the Android NDK to boost performance. Chapter 8 offers you an introduction to the NDK and integrating native code into your application using Java Native Interface (JNI) bindings.

The NDK is a complex technology, which can also reduce your application’s portability. Also, while good at increasing performance, the NDK doesn’t address multicore processing very well for heavy workloads. Fortunately, Google has eliminated this tedium and simplified the execute-on-multiple-cores task while achieving portability by introducing RenderScript. Chapter 8 introduces you to RenderScript and shows you how to use its compute engine (and automatically leverage CPU cores) to process images.

In the intervening chapters, we dive into using the Android SDK to solve real problems. You will learn tricks for effectively creating a user interface that runs well across device boundaries. You will become a master at incorporating the collection of hardware (radios, sensors, and cameras) that makes mobile devices unique platforms. We’ll even discuss how to make the system work for you by integrating with the services and applications provided by Google and various device manufacturers.

Keep a Level Eye on the Target

Throughout the book, you will see that we have marked most recipes with the minimum API level that is required to support them. Most of the recipes in this book are marked API Level 1, meaning that the code used can be run in applications targeting any version of Android since 1.0. However, where necessary, we use APIs introduced in later versions. Pay close attention to the API level marking of each recipe to ensure that you are not using code that doesn’t match up with the version of Android your application is targeted to support.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.157.39