Multithreading is essential if you want to create an Android app with a great user experience, but how do you know which techniques can help solve your problem? This practical book describes many asynchronous mechanisms available in the Android SDK, and provides guidelines for selecting the ones most appropriate for the app you’re building.
Author Anders Goransson demonstrates the advantages and disadvantages of each technique, with sample code and detailed explanations for using it efficiently. The first part of the book describes the building blocks of asynchronous processing, and the second part covers Android libraries and constructs for developing fast, responsive, and well-structured apps.
Understand multithreading basics in Java and on the Android platform
Learn how threads communicate within and between processes
Use strategies to reduce the risk of memory leaks
Manage the lifecycle of a basic thread
Run tasks sequentially in the background with HandlerThread
Use Java’s Executor Framework to control or cancel threads
Handle background task execution with AsyncTask and IntentService
Anders Goransson is a software architect, developer, trainer and international speaker. He holds a M.Sc. in Engineering Physics and has spent his whole career in the software industry. He started with moving bits and bytes in industrial automation systems in 2001, but as of 2005 he has focused on software for mobile devices. He embraced the Android OS as the most exciting mobile platform for the future already when the first smartphone was released publicly in 2008. Ever since, he has helped major handset manufacturers, carriers, financial institutions, start-ups, etc., with the transfer into the smartphone era.
The animal on the cover of Efficient Android Threading is mahi-mahi, or the common dolphinfish (Coryphaena hippurus). This ray-finned fish is a surface-dweller that is found in temperate, tropical, and subtropical waters. The name mahi-mahi translates to "very strong" in Hawaiian. Despite its alternate name of "dolphinfish," mahi-mahi are not related to the marine mammals. There are two species of dolphinfish: the common dolphinfish and the pompano dolphin. Along the English speaking coast of South Africa, these fish are often called by the Spanish name, Dorado.Mahi-mahi can grow up to 15–29 lb, seldom exceeding 33 lb. They can live up to five years, but average around four years. The mahi-mahi's compressed bodies have long dorsal fins that extend almost the entire body length. Mahi-mahi are characterized by their brilliant colors: broad golden flank with bright blues and greens on the side and back, and three diagonal black stripes on each side of the fish. These colors change after the fish is caught; out of water, mahi-mahi cycle through several colors before fading to a yellow-grey when it dies.Males and females are distinguished by their head shapes: males have prominent foreheads that stick out past the body, whereas females have rounded heads. Within the first year, both males and females are sexually mature, around 4–5 months. Females can spawn two to three times a year, producing 80,000–1,000,000 eggs per spawn.Mahi-mahi is primarily consumed in the US and Caribbean countries, though many European countries are increasing their consumption. Organizations such as the Monterey Bay Aquarium discourages consuming mahi-mahi imported and harvested by long line, which can injure or kill seabirds, sea turtles, and sharks as a bycatch. Mahi-mahi caught in the US Atlantic is classed as "Eco-Best" by the Environmental Defense Fund (EDF).The cover image is from Braukhaus Lexicon. The cover fonts are URW Typewriter and Guardian Sans. The text font is Adobe Minion Pro; the heading font is Adobe Myriad Condensed; and the code font is Dalton Maag's Ubuntu Mono.