Android Programming: Pushing the Limits

Android Programming: Pushing the Limits

English | 2014 | ISBN: 978-1-118-71730-1 | 434 Pages | PDF | 14 MB


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.

+

Building a Better Foundation

Fine-Tuning Your Development Environment

In this chapter, I covered the details of the Android SDK, some of the hidden features of the adb tool, how to stress test your application with the Monkey tool, how to use the ProGuard tool for obfuscating your code, and how the new build system based on Gradle works. I continued with more details on how to setup an Android Library Project or how to integrate a third-party library for your Android application.

Because the use of Git as a Source Code Management system for software development is quite widespread today, I also described how you can combine Git with various Servicesin order to make it easier for a team to work together.

The new IDE for developing Android applications, called Android Studio, contains a number of advanced features that many developers have rarely used. By understanding and mastering the refactoring features in this IDE, you can simplify complex tasks when you need to re-structure your code. It also helps to simplify existing code without the risk of introducing new bugs.

Finally, I outlined some of the more important details about the developer options settings in Android. It’s important to have a full understanding of how these work and how they can assist in development, debugging, and testing. Just remember to switch them all off and test your application without them to ensure that everything works as intended on a normal user’s device.

Developing software is more than simply writing code, regardless what kind of application or service you’re developing. For Android, mastering the tools is as important as the quality of your code, because when the tools are used to their fullest extent, the writing of the code becomes much easier and less error prone.

Efficient Java Code for Android

In this chapter, I covered some of the advanced Java features in Java SE 5.0 that with the modern JIT-enabled Dalvik VM are now safe to use on Android. Understanding and using these features will likely simplify your code, which makes the code easier to test and maintain. I also showed how to use the concurrency API from java. util.concurrent, instead of implementing your own queues or locks. Whenever you reinvent the wheel by implementing your own version of a basic class, you’re making a common but big mistake: You’ll have more code to test, more code that can cause bugs, and more code to maintain.

I also explained how to avoid many pitfalls when it comes to memory allocations. If your code creates a lot of temporary and short-lived objects, your application will most likely perform badly in the user interface. Understanding how to efficiently and safely reuse objects allows for a much smoother user experience.

To conclude the chapter, I covered three methods for using threads on Android but recommended using only two of them (AsyncTaskand Handler). Multithreading is a complex topic and often the cause of many bugs that are hard to find. Always try to use the ready-made utility classes for threads because they will make things simpler and allow you to focus on the functions of your own code.

Java is a powerful language that makes it easier for developers to express what they want to achieve and learning how to use the language most efficiently will make you a better developer and help you create highquality code.

Getting the Most Out of Components

  • Components, Manifests, and Resources
  • Android User Experience and Interface Design
  • Advanced User Interface Operations
  • Services and Background Tasks
  • Android IPC
  • Mastering BroadcastReceivers and Configuration Changes
  • Data Storage and Serialization Techniques
  • Writing Automated Tests

I’ve now covered the three central elements that are part of any Android application: the components, the manifest, and its resources. Understanding how these work and how to use the features they provide will take you a long way toward becoming a master Android developer.

Try to design your application around your components because they provide lifecycle callbacks that are managed by the system, allowing you to focus on what is important in your application. By always making the components a first priority, you’ll find it easier to build an application without ending up with tons of boilerplate code, something I’ve encountered far too often

The manifest is the actual definition of your application, and you need to take extra care in structuring it and the attributes you use for each element. Remember to declare all the features that your application requires, even the ones that may be obvious, such as a touchscreen or camera. A common error that I’ve seen during development is missing permissions. Be sure you always add a uses-permissionelement for the permissions your application requires.

In this chapter, I focused on the theory behind some of the concepts of interface design. You can learn much more about this topic than I could ever cover by going through all the guidelines and tips on the Android Design site. Also, I strongly recommend the books and other references found in the upcoming “Further Resources” section.

Being a great developer doesn’t automatically mean that you’re also a great UI designer. But by understanding the basics of how and why people react as they do to your user interface, you can avoid most design pitfalls. That said, nothing beats a good professional interaction and UI designer. If possible, make sure that you have one on your team and that she has an understanding of the Android Design guidelines.

Pushing the Limits

  • Advanced Audio, Video, and Camera Applications
  • Secure Android Applications
  • Maps, Location, and Activity APIs
  • Native Code and JNI
  • The Hidden Android APIs
  • Hacking the Android Platform
  • Networking, Web Service, and Remote APIs
  • Communicating with Remote Devices
  • Google Play Services
  • Distributing Applications on Google Play Store