Skip to main content

2012 | Buch

Pro Android Apps Performance Optimization

insite
SUCHEN

Über dieses Buch

Today's Android apps developers are often running into the need to refine, improve and optimize their apps performances. As more complex apps can be created, it is even more important for developers to deal with this critical issue.

Android allows developers to write apps using Java, C or a combination of both with the Android SDK and the Android NDK. Pro Android Apps Performance Optimization reveals how to fine-tune your Android apps, making them more stable and faster. In this book, you'll learn the following:

How to optimize your Java code with the SDK, but also how to write and optimize native code using advanced features of the Android NDK such as using ARM single instruction multiple data (SIMD) instructions (in C or assembly) How to use multithreading in your application, how make best use of memory and how to maximize battery life How to use to some OpenGL optimizations and to Renderscript, a new feature in Android 3.0 (Honeycomb) and expanded in Android 4.0 (Ice Cream Sandwich).

After reading and using this book, you'll be a better coder and your apps will be better-coded. Better-performing apps mean better reviews and eventually, more money for you as the app developer or your indie shop.

Inhaltsverzeichnis

Frontmatter
Chapter 1. Optimizing Java Code
Abstract
Many Android application developers have a good practical knowledge of the Java language from previous experience. Since its debut in 1995, Java has become a very popular programming language. While some surveys show that Java lost its luster trying to compete with other languages like Objective-C or C#, some of these same surveys rank Java as the number 1 language popularity-wise. Naturally, with mobile devices outselling personal computers and the success of the Android platform (700,000 activations per day in December 2011) Java is becoming more relevant in today’s market than ever before.
Hervé Guihot
Chapter 2. Getting Started With the NDK
Abstract
The Android Native Development Kit (NDK) is a companion to the SDK and is what you use when you want part or all of your Android application to use native code. While bytecode needs to be interpreted by a virtual machine, native code can be directly executed by the device’s processor without any intermediate step, making execution faster, and sometimes much faster. The Dalvik Just-In-Time (JIT) compiler is compiling the bytecode into native code, making your applications faster by having to interpret the code less often (and ideally, only once) since it will use the native code it generated whenever it is available. When you use the NDK, the compilation into native code occurs on your development environment and not on the Android device. You may be wondering why you would need to worry about the NDK since the Dalvik JIT compiler can generate native code dynamically and therefore you could write your application in Java using the SDK. This chapter covers the reasons why you may need to use the NDK and the various ways to use it.
Hervé Guihot
Chapter 3. Advanced NDK
Abstract
Chapter 2 showed you how to set up a project using the Android NDK and how you could use C or C++ code in your Android application. In many cases, this is as far as you will need to go. However, there may be times when digging a little deeper is required to find what can be optimized even more.
Hervé Guihot
Chapter 4. Using Memory Efficiently
Abstract
Applications spend a significant part of their time dealing with data in memory. While many developers are aware of the need to try to use as little memory as possible on devices like phones or tablets, not all realize the impact of memory usage on performance. In this chapter, you will learn how choosing the right data type and how arranging your data in memory can boost your application’s performance. Also, we will review a basic yet often overlooked feature of Java: memory management using garbage collection and references.
Hervé Guihot
Chapter 5. Multithreading and Synchronization
Abstract
Chapter 1 introduced the concept of the main thread, or UI thread, in which most events are handled. Even though you are not prevented from executing all your code from within the main thread, your application typically uses more than one thread. As a matter of fact, several threads are created and run as part of your application even if you don’t create new threads yourself. For example, Eclipse’s DDMS perspective shows these threads when an application runs on an Android 3.1-based Galaxy Tab 10.1:
  • main
  • HeapWorker
  • GC (Garbage Collector)
  • Signal Catcher
  • JDWP (Java Debug Wire Protocol)
  • Compiler
  • Binder Thread #1
  • Binder Thread #2
Hervé Guihot
Chapter 6. Benchmarking and Profiling
Abstract
Being able to measure performance is required in order to determine whether optimizations are needed, and whether the optimizations actually improved anything.
Hervé Guihot
Chapter 7. Maximizing Battery Life
Abstract
With little power comes great responsibility. Android portable devices run on batteries, and everything your application does draws a certain amount of power from the device’s battery. Since most devices are charged at home during the night and will be used during the day when there is no opportunity to recharge the battery, most device owners expect the battery to last at least about 12 hours. Typical usage may cause the battery to drain more quickly: for example, charging stations were available at Google I/O as many were using their devices for periods of time longer than usual during the event.
Hervé Guihot
Chapter 8. Graphics
Abstract
Quite often you’ll have to spend a lot of time defining what your application should look like. Whether it is an e-mail application using standard Android widgets or a game using OpenGL ES, what your applications looks like is one of the first things people will notice when browsing application stores like Android Market or Amazon Appstore.
Hervé Guihot
Chapter 9. RenderScript
Abstract
Introduced in Honeycomb (API level 11), RenderScript is a new framework targeted at high-performance 3D rendering and compute operations. While RenderScript was already used back in Android 2.1 (Éclair), Honeycomb is the first Android version where RenderScript is made publicly available.
Hervé Guihot
Backmatter
Metadaten
Titel
Pro Android Apps Performance Optimization
verfasst von
Hervé Guihot
Copyright-Jahr
2012
Verlag
Apress
Electronic ISBN
978-1-4302-4000-6
Print ISBN
978-1-4302-3999-4
DOI
https://doi.org/10.1007/978-1-4302-4000-6

Premium Partner