This edition first published 2014
2014 Erik Hellman
Registered office
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom
For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com.
The right of the author to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought.
Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley and Sons, Inc. and/ or its affiliates in the United States and/or other countries, and may not be used without written permission. Android is a trademark of Google, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Ltd. is not associated with any product or vendor mentioned in the book.
A catalogue record for this book is available from the British Library.
ISBN 978-1-118-71737-0 (paperback); ISBN 978-1-118-71730-1 (ePDF); 978-1-118-71735-6 (ePub)
Set in 9.5 pt Myriad Pro by Indianapolis Composition Services
Printed in the United States by Bind-Rite
Dedication
This book is dedicated to my amazing dad, Ingemar Hellman, who taught me programming when I was nine years old. None of this would have been possible if it werent for all the amazing things he taught me.
Erik Hellman, Second generation software developer
Publishers Acknowledgements
Some of the people who helped bring this book to market include the following:
Editorial and Production
VP Consumer and Technology Publishing Director: Michelle Leete
Associate DirectorBook Content Management: Martin Tribe
Associate Publisher: Chris Webb
Project Editor: M. Faunette Johnston
Copy Editor: Melba Hopper
Technical Editor: Erik Westenius
Editorial Manager: Jodi Jensen
Senior Project Editor: Sara Shlaer
Editorial Assistant: Annie Sullivan
Marketing
Associate Marketing Director: Louise Breinholt
Marketing Manager: Lorna Mein
Senior Marketing Executive: Kate Parrett
Marketing Assistant: Polly Thomas
Composition Services
Compositor: Jennifer Goldsmith, Andrea Hornberger
Proofreader: Wordsmith Editorial
Indexer: Potomac Indexing, LLC
About the Author
Erik Hellman grew up in the small town of Borlnge in the middle of Sweden and currently lives in the city of Malm with his wife. From an early age he showed a great interest in all kinds of technology, much thanks to his father. This interest has carried on over the years and he likes to spend time tinkering with all kinds of technology, be it hardware or software.
Erik currently works as a developer consultant at Factor10. He previously worked for Sony Mobile as one of the lead architects for their Android development and later as a research engineer where he participated in the development of the next generation of mobile solutions from Sony.
Erik has a lifetime of experience with software development and programming. His father taught him how to write code in Turbo Pascal at the age of nine, as well as how to design relational databases in Oracle 3 on his old IBM AT 286. Much later, Erik studied Software Engineering at Blekinge Institute of Technology where he also worked as an assistant teacher in various software engineering courses.
Erik can often be found at various developer conferences where he likes to speak about cutting-edge software technologies. You can also find out more about Erik and his other hobbies at his blog (http://blog.hellsoft.se) or follow him on Google+ (http://gplus.to/ErikHellman) or Facebook (https://www.facebook.com/ErikHellman).
Acknowledgements
First of all, Id like to thank my wife Kaisa-Leena. Without her love, support, and infinite patience with me during the writing of this book, this book would never have been finished.
A big thank you goes out to all my friends and former colleagues at Sony Mobile. Almost everything Ive learned about Android and mobile technologies came from my years working with all of you. Im extremely proud to have been part of the team that built the Xperia series of devices. A special thank you to my former boss, Henrik Bengtsson, and his team at the Sony Mobile Research in Lund.
Finally, Id like to thank my editors; Faunette, Melba, Erik, and all the people working at Wiley for helping me write this book. A big thanks goes to my technical editor Erik Westenius for his eye for details and making sure that my code and examples are understandable. Also, a thank you to Kristoffer berg at Sony Mobile for giving me valuable input on the UI design sections.
If youre reading this book, youre probably familiar with the Android platform, smartphones, and application development. Youre well aware of the tremendous growth of Android devices over the last few years and the potential that the platform holds for application developers. I could give you specific numbers and statistics about Android, but that wouldnt serve much purpose because those numbers most likely would be invalid by the time you read this book. Its enough to say that the Android platform is here to stay, and you can expect its growth to continue for the foreseeable future.
All of this is great news to people like you and me. Those of us who are aiming to becoming experts at Android development face a bright future. The demand for skilled application developers for Android is growing every day, and at the same time, the demand on developers is growing because the features that users want and the possibilities provided by the new technologies require us to constantly think ahead.
Although Google provides a great set of tools and APIs to help you perform your magic, you still need to push yourself on what you can now do with Android. That is the goal of this book: to push the limits of the Android platform and build ever more advanced applications.
Youve probably written a few Android applications already and are eager to learn more advanced APIs and tricks. Perhaps you generally program using Java, but you dont have any problems learning a new language. As a developer, youre not afraid to try out new things, be it a new IDE or a brand new API. You like to test all the latest features, and you dont become discouraged when things initially fail.
While you can find plenty of introductory books on Android development, this is not such a book. Instead, this book is targeted toward developers who have previous experience with application development for Android. You know all the basics and how to create an app using the Activity , Service , BroadcastReceiver , and ContentProvider classes. Youre familiar with the core concept of the application manifest and the different types of application resources for Android. If you can build a simple Android application in a matter of minutes, youre well prepared for the contents of this book.