Contents

Contents at a Glance

About the Author

About the Technical Reviewers

Acknowledgments

Introduction

imagesChapter 1: Optimizing Java Code

How Android Executes Your Code

Optimizing Fibonacci

From Recursive To Iterative

BigInteger

Caching Results

android.util.LruCache<K, V>

API Levels

Fragmentation

Data Structures

Responsiveness

Lazy initializations

StrictMode

SQLite

SQLite Statements

Transactions

Queries

Summary

imagesChapter 2: Getting Started With the NDK

What Is In the NDK?

Mixing Java and C/C++ Code

Declaring the Native Method

Implementing the JNI Glue Layer

Creating the Makefiles

Implementing the Native Function

Compiling the Native Library

Loading the Native Library

Application.mk

Optimizing For (Almost) All Devices

Supporting All Devices

Android.mk

Performance Improvements With C/C++

More About JNI

Native Activity

Building the Missing Library

Alternative

Summary

imagesChapter 3: Advanced NDK

Assembly

Greatest Common Divisor

Color Conversion

Parallel Computation of Average

ARM Instructions

ARM NEON

CPU Features

C Extensions

Built-in Functions

Vector Instructions

Tips

Inlining Functions

Unrolling Loops

Preloading Memory

LDM/STM Instead Of LDR/STD

Summary

imagesChapter 4: Using Memory Efficiently

A Word On Memory

Data Types

Comparing Values

Other Algorithms

Sorting Arrays

Defining Your Own Classes

Accessing Memory

The Cache's Line Size

Laying Out Your Data

Garbage Collection

Memory Leaks

References

APIs

Low Memory

Summary

imagesChapter 5: Multithreading and Synchronization

Threads

AsyncTask

Handlers and Loopers

Handlers

Loopers

Data Types

Synchronized, Volatile, Memory Model

Concurrency

Multicore

Modifying Algorithm For Multicore

Using Concurrent Cache

Activity Lifecycle

Passing Information

Remembering State

Summary

imagesChapter 6: Benchmarking And Profiling

Measuring Time

System.nanoTime()

Debug.threadCpuTimeNanos()

Tracing

Debug.startMethodTracing()

Using the Traceview Tool

Traceview in DDMS

Native Tracing

Logging

Summary

imagesChapter 7: Maximizing Battery Life

Batteries

Measuring Battery Usage

Disabling Broadcast Receivers

Disabling and Enabling the Broadcast Receiver

Networking

Background Data

Data Transfer

Location

Unregistering a Listener

Frequency of Updates

Multiple Providers

Filtering Providers

Last Known Location

Sensors

Graphics

Alarms

Scheduling Alarms

WakeLocks

Preventing Issues

Summary

imagesChapter 8: Graphics

Optimizing Layouts

RelativeLayout

Merging Layouts

Reusing Layouts

View Stubs

Layout Tools

Hierarchy Viewer

layoutopt

OpenGL ES

Extensions

Texture Compression

Mipmaps

Multiple APKs

Shaders

Scene Complexity

Culling

Render Mode

Power Consumption

Summary

imagesChapter 9: RenderScript

Overview

Hello World

Hello Rendering

Creating a Rendering Script

Creating a RenderScriptGL Context

Extending RSSurfaceView

Setting the Content View

Adding Variables to Script

HelloCompute

Allocations

rsForEach

Performance

Native RenderScript APIs

rs_types.rsh

rs_core.rsh

rs_cl.rsh

rs_math.rsh

rs_graphics.rsh

rs_time.rsh

rs_atomic.rsh

RenderScript vs. NDK

Summary

Index

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

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