Android Programming
eBook - ePub

Android Programming

Pushing the Limits

Erik Hellman

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Android Programming

Pushing the Limits

Erik Hellman

Book details
Book preview
Table of contents
Citations

About This Book

Unleash the power of the Android OS and build the kinds of brilliant, innovative apps users love to use

If you already know your way around the Android OS and can build a simple Android app in under an hour, this book is for you. If you're itching to see just how far you can push it and discover what Android is really capable of, it's for you. And if you're ready to learn how to build advanced, intuitive, innovative apps that are a blast to use, this book is definitely for you.

From custom views and advanced multi-touch gestures, to integrating online web services and exploiting the latest geofencing and activity recognition features, ace Android developer, Erik Hellman, delivers expert tips, tricks and little-known techniques for pushing the Android envelope so you can:

  • Optimize your components for the smoothest user experience possible
  • Create your own custom Views
  • Push the boundaries of the Android SDK
  • Master Android Studio and Gradle
  • Make optimal use of the Android audio, video and graphics APIs
  • Program in Text-To-Speech and Speech Recognition
  • Make the most of the new Android maps and location API
  • Use Android connectivity technologies to communicate with remote devices
  • Perform background processing
  • Use Android cryptography APIs
  • Find and safely use hidden Android APIs
  • Cloud-enable your applications with Google Play Services
  • Distribute and sell your applications on Google Play Store

Learn how to unleash the power of Android and transform your apps from good to great in Android Programming: Pushing the Limits.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Android Programming an online PDF/ePUB?
Yes, you can access Android Programming by Erik Hellman in PDF and/or ePUB format, as well as other popular books in Computer Science & Open Source Programming. We have over one million books available in our catalogue for you to explore.

Information

Publisher
Wiley
Year
2013
ISBN
9781118717356
Edition
1
Part I
Building a Better Foundation
Chapter 1 Fine-Tuning Your Development Environment
Chapter 2 Efficient Java Code for Android
Chapter 1
Fine-Tuning Your Development Environment
Depending on what you’re developing, you have different choices when it comes to the tools you can use. Your requirements on the development environment differs if you’re writing an HTML5 application or if you’re developing a server-side application in Java. Some platforms offer more choice than others, and as I describe next, developing Android applications gives you a lot of choice for your development environment.
I begin this chapter with some more advanced internals of the Android SDK and how you can use them in your daily development and how they can assist you in improving the quality of your application. I continue by describing how to structure your code projects in an optimal way for reuse by using library projects. You also learn how to take version control to a new level by integrating Git with a code-review tool called Gerrit. As a developer, you will spend most of your time using the IDE tool. While the Eclipse IDE is still supported by Google, they are now pushing developers to use their new Android Studio IDE for all Android projects. So, I give an introduction to Android Studio as well as to the new build system called Gradle. Finally, I go through the developer settings that are available on Android devices.
Operating Systems for Android Development
This is probably the one topic you don’t have to worry about. Either you can pick the operating system on your computer used for development, or it is limited by the IT-policies of your employer. For most Android developers, any of the officially supported operating systems works fine. However, there are situations where the choice will matter.
Google supports Windows, Linux, and OS X for developing Android applications. Although Windows is officially supported by the Android SDK, you’ll have problems if you decide to do advanced development, especially when it comes to writing native applications or building your own custom ROM. The best choice is either Linux or OS X. If possible, try to have one of these as your primary operating system, and you’ll run into far fewer problems. Another reason for avoiding Windows on your Android development environment is that you won’t need to install new USB drivers for every Android device you work on.
Advanced Android SDK Tools
After you have your operating system and the required (and recommended) tools installed on your computer, you can focus on the Android SDK. You will find the download for your operating system and the latest installation instructions at http://developer.android.com/sdk. Android Studio comes with an SDK bundle that is completely managed from within the IDE, but if you prefer to have a standalone version you can download that as well.
Make sure that you always keep the SDK up to date and that you download the APIs for all the Android versions that you’re developing for. The easiest way to update your standalone Android SDK is to run the update tool from the command prompt:
$ android update sdk --no-ui
Inside the Android SDK folder, you will find a number of subfolders. From a tools perspective, only the platform-tools and tools folders are of interest for now. I will introduce some of these tools and explain how to use them, starting with the adb (Android Debug Bridge) tool. If you are frequently using the command line tools in the Android SDK I recommend that you add the path to these folders in your local PATH variable.
You can find the official documentation for most of the tools in the Android SDK at http://developer.android.com/tools/help/index.html.
The adb Tool
In the platform-tools folder, you will find the adb tool that is used to communicate with your device to install and start apps during development. In earlier versions of the Android SDK, this tool was found in the tools directory, but it has since been moved. Besides being used for installing, starting, and debugging applications from your IDE, the adb tool enables you to manually call many of the low-level operations on your Android device for debugging purposes. To list all the commands available, simply type adb help all in your terminal (Linux or Mac OS X) or command prompt (Windows).
Some common adb commands are
■ adb devices—List all connected Android devices and Emulators.
■ adb push <local> <remote>—Copy a file from your computer to a device (usually on the SD card).
■ adb pull <remote> <local>—Copy a file from the device to your computer.
adb and Multiple Devices
If you ever need to develop and debug an application for two or more devices simultaneously, such as for a multiplayer game or an instant-message application, adb needs an additional argument to know which device you want to address. You do so by adding –s <serial number> as the first parameter to adb. You can see the serial number for your connected devices by executing the adb devices command. To run the logcat command on a specific device, run the following:
$ adb devices
List of devices attached
0070015947d30e4b device
015d2856b8300a10 device
$ adb –s 015d2856b8300a10 logcat
When you have multiple devices connected or emulators started a dialog box will appear when you launch your application in your IDE.
Mastering Logcat Filtering
Logging is an important part of Android application development. Although using breakpoints and a debugger from your IDE is extremely powerful when you want to follow the execution flow and inspect the values and state of different variables, simply reading the output from logcat can sometimes be more efficient. Android logging is handled by the logcat function, which is usually integrated in your IDE but can also be called via the adb command.
Because Android outputs all system and application log messages to the same stream, it can become quite complicated to find the messages that relate to your ...

Table of contents