Android for beginners. Developing apps using Android Studio Barbara Hohensee Translated by Amit Dilip Dharma Android for beginners. Developing apps using Android Studio Written By Barbara Hohensee Copyright 2014 Barbara Hohensee All rights reserved Distributed by Babelcube, Inc. www.babelcube.com Translated by Amit Dilip Dharma Babelcube Books and Babelcube are trademarks of Babelcube Inc.
Android for beginners
Developing Apps with Android Studio
Barbara Hohensee
First edition
Preface
T he objective of this book is to give an insight into Android programming based on practical app projects. The apps have different objectives and target groups and hence one can extend and develop them further based on his/her Android knowledge.
Thanks to active programming, the users will be quickly acquainted with the work environment and will learn how to solve problems in Android step-by-step. Android Studio, which is a completely new development environment, will be used for programming.
Target group of this book
T his book is intended for everyone who is interested in the Android app development and would like to learn the same with DIY examples.
Requirements for the computer
W hat are the requirements for the computer? You can select any modern operating system of your choice (Windows XP, Windows 7/8, Mac OS X and Linux). You will need Administrator rights for installation.
Android telephone or tablet
S ince an emulator is integrated in Android Studio, you can start Android development even without an Android telephone or a tablet.
Testing with the emulator makes sense since the app can be tested with all possible Android versions, screen sizes and resolutions. In addition, you can also use specific debugging options in the emulator such as Hierarchy View which can otherwise be used only with a Google developer telephone. However, the emulator has its limitations. For example: One cannot make telephone calls, the options to test the GPS are restricted, the accelerator in the telephone responds to movements; one cannot hold the emulator in hand, which makes it difficult or even impossible to test the games. If you are not well-versed with an Android device until now, you might ask which would be an ideal choice from a developers point of view. I have given a few pointers here, which will hopefully make the decision making easier.
Which Android version should the telephone use? The latest? Probably yes, when you are thinking of developing an app for the latest version of Android. If you want to develop apps for the masses, you must know the Android versions used by the masses. Based on a test conducted by Google at the end of October 2013, the distribution is as follows: Android 2.2 Froyo API 8 => 1.7% Android 2.3.3 - 2.3.7 Gingerbread API 10 => 26.3% Android 3.2 Honeycomb API 13 => 0.1% Android 4.0.3 - 4.0.4 Ice Cream Sandwich API 15 => 19.8% Android 4.1.x Jelly Bean API 16 => 37.3% Android 4.2.x Jelly Bean API 17 => 12.5% Android 4.3 Jelly Bean API 18 => 2.3% This means that Android 4.x versions are used by than 70% users. Since the new Android Version 4.4 KitKat has been released, this statistics will soon further improve in favour of Android 4.x and probably get worse for Froyo and Gingerbread. Screen size and resolution are other factors that can influence the purchase of a developer device. Testing the layout of an app is extremely important.
You can imagine that nobody would like an app where the text is not legible or the buttons are too small and one always accidentally clicks on 3 other things when one wants to click on Next. My tip: search for the most commonly used screen resolutions in Google. In October 2013, the vast majority of devices had a resolution of 480x800 pixels. For the latest information, visit: http://developer.android.com/about/dashboards/index.html
Java knowledge
K nowledge of Java is recommended. However, you can also start with this book and refer to a Java book wherever you face problems due to the lack of Java knowledge.
How this book is structured?
T his book has 3 parts: Part 1: The first part deals with the installation and configuration of Java and Android Studio.
How this book is structured?
T his book has 3 parts: Part 1: The first part deals with the installation and configuration of Java and Android Studio.
You will get an overview of the development environment and an insight how the project structure of an Android app looks in Android Studio. The 1st part concludes with the creation and commissioning of a test app project. This will ensure that Android Studio functions as expected. You would not appreciate if you realise some parts are missing when you are already in the middle of a book, would you? Part 2: The second parts deals with the creation of different app projects. Each of the apps begins with a plan. The practical implementation of the app idea is then explained.
Among other things, you will learn the following on the course of completing the apps: Creating different screen layouts Supporting different screen sizes Designing clickable buttons and assigning functions to them Using and managing the resources Creating a series of different activities Creating a database Adding an ActionBar Creating animation Making calculations in the app Using Google libraries Working with Google maps Integrating ads in the app Providing support for different languages Preparing the app for the Android market Complete source code is provided for each app project; refer to the links. Part 3: Advanced sections are included in the third part. These include: Gradle Connecting your project with Github Product Flavours - Build Types - Build Variants GameEngines AndEngine and libGDX Links for the source code and more information is given in the annexe.
About Android Studio
I n May 2013, Google presented the new development environment for Android apps during the developers conference. The new IDE is intended to replace Eclipse and is based on the "IntelliJ IDEA" Java-IDE by JetBrains. The powerful Code-Editor with built-in functions such as "Smart Editing", which ensures better legible code, or "Advanced Code Refactoring is one of the core components of Android Studio.
The Gradle Build System is another novel feature introduced with Android Studio. It replaces the Ant Build System used until now. Gradle allows developers to create various configurations so that different app versions can be produced using the same code. This is really useful when you want to release a free and a paid version of an app. Gradle improves the reusability of the code and the integration on a build server. Similar to Eclipse, the layout of an app can be created either in the text editor or in a graphical interface (design mode) in Android Studio.
The design mode was further improved for Android Studio. The app layout shows the layout for different resolutions, Android versions and country-specific special features in the preview. A series of new features and services were integrated in Android Studio. The developer console gives developers tips for optimising an app and it also allows uploading the string files (strings.xml) to be translated to a central server, and to insert them again in the app after translating them. Android Studio was also enhanced with an option to add Google Cloud Messaging (CGM) to the project that allows sending messages to the app and receiving the messages from the app on the cloud server. It is not a new feature to connect an Android app with a cloud server/ App Engine Server app.
Next page