Rachit Technology

Introduction to Android Development Using Eclipe and ADT

1. Overview

"Introduction to Android Development Using Eclipe and ADT" covers overview of Android Programming concepts from development to deployment.

Prerequisite : Understanding of Java language and programming is must to use this tutorial.

1.1 Programming Language

1. Basic Of Programming
2. History
3. Types of Programming Languages
4. Compilers and Interpreters

1. Basic Of Programming

A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs to control the behavior of a machine or to express algorithms.

Computer programming (often shortened to programming) is a process that leads from an original formulation of a computing problem to executable computer programs. Programming involves activities such as analysis, developing understanding, generating algorithm

2. History

The only mechanical device that existed for numerical computation at the beginning of human history was the abacus, invented in Sumeria circa 2500 BC

In the 1880s, Herman Hollerith invented the recording of data on a medium that could then be read by a machine.

A punched card, punch card, IBM card, or Hollerith card is a piece of stiff paper that contained either commands for controlling automated machinery or data for data processing applications. Both commands and data were represented by the presence or absence of holes in prefefined format

As of 2012 there are still some voting machine which use punched cards

In 1940’s an important phenomena changed history of Computer Programming

The invention of the von Neumann architecture allowed computer programs to be stored in computer memory

Earlier Computer Contains fixed programs like Word Processors, changing program requires rewriting or redesigning of machine.

Alan Turing was a British pioneering computer scientist, mathematician, logician, cryptanalyst, philosopher, mathematical biologist, and marathon and ultra distance runner. He was highly influential influential in the development of computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general purpose computer. He is considered as father of theoretic computer science and AI.

3. Types of Programming Languages

LLP (Low Level Programming Languages)

Can covert machine code without compiler and interpreter. They run fast and simple to use.

1st Gen LLP

Machine Code, true machine code which is in binary format, Decimal, hexadecimal, octal format are ready by loader.

Binary Number Systems – Represents text using binary number systems, ASCII, BCD ( Binary Coded Decimals )

2nd Gen Programming Language

Assembly Programming Language. Use Macros. Second generation languages provide one abstraction level on top of the machine code. Assemblers produce object files that can link with other object files or be loaded on their own.

High Level of Programming

In computer science, a high-level programming language is a programming language with strong abstraction from the details of the computer.

It’s FREE Form Language

"High-level language" refers to the higher level of abstraction from machine language. Rather than dealing with registers, memory addresses and call stacks, high-level languages deal with variables, arrays, objects, complex arithmetic or boolean expressions,

In 1954 Fortran was first widely used High-Level programming Language.

There are three general modes of execution for modern high-level languages:

Interpreted - When code written in a language is interpreted, its syntax is read and then executed directly, with no compilation stage.
An interpreter is a program that reads in as input a source program, along with data for the program, and translates the source program instruction by instruction. For example, the Java interpreter java translate a .class file into code that can be executed natively on the underlying machine.

Compiled -
Machine code generation
Some compilers compile source code directly into machine code. E.g. Assemlbly Language.
Intermediate representations When code written in a language is compiled to an intermediate representation, that representation can be optimized or saved for later execution without the need to re-read the source file. When the intermediate representation is saved, it may be in a form such as byte code. The intermediate representation must then be interpreted or further compiled to execute it. Virtual machines that execute byte code directly or transform it further into machine code have blurred the once clear distinction between intermediate representations and truly compiled languages.
Source-to-Source Translated or Trans-compiled ( e.g. C / Eiffel )

1.2 Understanding and implementation of open source ecosystems

View Detail Presention on Slidshare ( Opens in new window )

1.3 Java High Level Overview

Java is set of several software programs developed by Sun Microsystem (James Gosling, Mike Sheridan, and Patrick Naughton) in 1991.

Oracle brought Java in 2009 – 2010

Java language is written in c, c++, java

As of Sep-2015 - Current Stable build of Java is 8 ( 1.8.0 ) and preview build is 9

Java is released under GNU License in 2006.

Various Releases and inclusions :

Java 1.0 released in 1995 ( Provided WORA platform )

Java 1.1 Released in 1997 ( Includes AWT, JDBC, JavaBeans, RMI,JIT )

Java 1.2 Released in 1998 ( Includes J2EE, J2SE, Collctions framework)

Java 1.3 Released in 2000 (Includes JVM, JNDI, JPDA )

Java 1.4 Released in 2002 (Includes XSLT, iPV6 support )

Java 1.5 Released in 2004 (Includes Annotations, Generics , Enumerations, Varargs )

Java 1.6 Released in 2006 (Enhancements to GUI, JAXB,JVM). Oracle released various updates for 1.6

Java 1.7 Released in 2011 (Strings in switch , Timesort used for sorting instead of mergesort )

After 7 Oracle declared they will go back to 2 year cycle but delayed 8 for security fixes

Java 1.8 Released in 2014 (Support for lambda expressions which make multiple inheritances possible in java, removal of long term objects from heap)

Java 1.9 Scheduled for 2016 currently in beta( Money and currency API, multi-gigabyte heaps)

Java 1.10 Scheduled for 2018( Speculations of objects without identity, 64 bit arrays to support large data sets)

Five Primary Goals in creation of Java language :

1. Simple, object-oriented and familiar

2. Robust and Secure

3. Architecture-neutral and portable

4. High performance

5. Interpreted, threaded and dynamic

JVM ( Java Virtual Machine ) - The Java virtual machine is an abstract (virtual) computer defined by a specification.

Java Overview (https://docs.oracle.com/javase/tutorial/java/index.html)


Exercise: Understand Interface, Interface Vs Abstract Classes, When to use Interface, When to user Abstract Classes

Abstract Classes - An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed

Consider using Abstract classes if any of these statements apply to your situation:

1. You want to share code among several closely related classes.

2. You expect that classes that extend your abstract class have many common methods or fields, or require access modifiers other than public (such as protected and private).

3. You want to declare non-static or non-final fields. This enables you to define methods that can access and modify the state of the object to which they belong.

Consider using interfaces if any of these statements apply to your situation: - An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed

1. You expect that unrelated classes would implement your interface. For example, the interfaces Comparable and Cloneable are implemented by many unrelated classes.

2. You want to specify the behavior of a particular data type, but not concerned about who implements its behavior. You want to take advantage of multiple inheritance of type

Annotations - Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they annotate.

1. Useful for Information to the compiler - Annotations can be used by the compiler to detect errors or suppress warnings

2. Compile time and Deployment time processing - Software tools can process annotation information to generate code, XML files, and so forth.

3. Runtime Processing - Some annotations are available to be examined at runtime

4. E.g. @Override void mySuperMethod() { ... } myString = (@NonNull String) str; class UnmodifiableList implements @Readonly List<@Readonly T> { ... } void monitorTemperature() throws @Critical TemperatureException { ... }

5. Frameworks like hibernate where lots of mapping is required uses Annotations.

6. Use in Android – Replaces code that is common in Android , speeds up development, it uses dependency injection design patterns.

Generics - Generics add stability to your code by making more of your bugs detectable at compile time. Read Generics tutorial by Gilad Bracha. generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs.

Enabling programmers to implement generic algorithms. By using generics, programmers can implement generic algorithms that work on collections of different types, can be customized, and are type safe and easier to read.

Packages - To make types easier to find and use, to avoid naming conflicts, and to control access, programmers bundle groups of related types into packages

2. Android Overview

Evolution of Smartphones Background

First telephone call was made on March 10, 1876 by Alexander Graham Bell. After that Pager continues to dominate wireless communication early 1990’s. From early 1960’s to mid 1990’s pager continues to evolve. However by mid 1990’s, cellular technology became cheaper and more widely available, causing cellular to displace paging as a commercial product. Still pagers are used as niche low cost products in hospitals and retail sectors.

A mobile phone (Cell phone) is an instrument, which allows user to receive telephone over a radio link, using cellular network. A telephone call can transmit voice, data, text messaging, mms, email and short- range wireless communication using Bluetooth, games, business applications and many more. A mobile phone, which delivers above said capabilities and more are called as Smartphones.

First hand-held cell phone was demonstrated by John Mitchell and Martin Cooper on Motorola in 1973 weighting 1 Kg, it took 10 years for first commercial cell phone. Today 87% world population owns a cell phone, with Smartphone usage increasing every day.

Mobile Phone landscape has been evolved in last 2 decades. It is estimated more than billion Smartphone Users end of 2014. With World population 7 billion and 87% world owning cell phone, end of 2014 there will be approximately 1 smart phone in every 5 people in world

What is Smartphone?

A Smartphone is advanced version of cell phone, which allows user to perform more advanced computing capabilities other than receiving and sending phone calls. Today 90% of Smartphone devices are driven by Google’s Android and Apple’s iOS mobile operating systems.

When did it started?

Concept of building telephone and computer were first conceptualized in 1973, but first commercial version of Smartphone was launched by Erissson in 1997. In early 1990’s many users popularly used a dedicated PDA (Personal Digital assistant) device. As name suggests PDA’s mainly used to manage appointment calendar, to-do list, address book, calculator. Most of PDA’s has a touchscreen and memory card for data storage. PDA’s have became mostly obsolete with widespread usage of Smartphones.

Many of Smartphones before Android, iOS and blackberry used to run on Symbian Operating System. Operating system is a collection of software that manages computer hardware and provides common service to front programs.

Japanese firm NTT Docomo was first company to achieve million subscribers in early 2001 in Japan; outside Japan it was still a rare feature. Blackberry based Smartphone’s got lot of good responses in 2006, which were very popular in business people and young people. Post 2006 Nokia company launched N series, which was popular due to its entertainment-focused phones. In 2007, world witness a drastic change in Smartphone when Apple Inc introduced one of the first phones to use ‘multi-touch’ interface named ‘iPhone’. iPhone was the first phone used its large touch screen for direct input using fingers, instead of traditional keyboard or stylus which was common for Smartphone.

In 2008 Android released first phone (HTC Dream) also called was T- Mobile G1.

Since 2007/08 most of previous Smartphone market is captured by Android and iOS. With every day people are relying heavily on Mobile phones for daily routine. There is huge surge in mobile devices, providers and applications.

Android™ Operating System

Android was founded in Palo Alto-California, in October 2003 by Andy Rubin, Rich Miner, Nick Sears and Chris White. Google acquired Android in 2005 (approx. $50 million min). After acquisition Rubin developed a mobile device platform powered by Linux kernel. Android is released by Google under open source licenses (Apache , GNU GPL ), which encourages majority of enthusiasts develop new features for advanced users. Android launched its first commercial phone HTD Dream on October 22, 2008. Since 2008 Android has released various updates of operating systems, which include new features and bug fixes for previous releases. It’s written in C, C++

Version Code Name Release Date API Level Updates
1.5 Cupcake April-2009 3 Widgets, MPEG4, 3GP support
1.6 Donut September-2009 4 Speech synthesis, WVGA
2.0 Éclair October-2009 5 Bluetooth 2.1, live wallpapers
2.2 Froyo May-2010 8 C2DM (Cloud to Device Messaging), push notifications, USB tethering, Adobe Flash
2.3 Gingerbread Dec-2010 9 NFC tag reading, multiple cameras,
3.0 Honeycomb Feb-2011 11 System bar, browser tabs,
4.0 Ice Cream Sandwich Oct-2011 14 Face unlock feature, Wifi Direct(Connect devices)
4.1 Jelly Bean July-2012 16 Audio Chaining
4.4 Kitkat Oct-2013 19 ART ( Android Run-Time) replacing Dalvik as test
5.0 Lollipop Nov-2014 21 ART completely replace Dalvik, 64 Bit
6.0 Marshmallow Oct-2015 23 Redesigned permission model, Doze power scheme

3. Android Architecture

Application Framework

The application framework is used most often by application developers.

Binder Inter-Process Communication (IPC)

The Binder Inter-Process Communication (IPC) mechanism allows the application framework to cross process boundaries and call into the Android system services code. This enables high level framework APIs to interact with Android system services.

System Services

Functionality exposed by application framework APIs communicates with system services to access the underlying hardware. Services are modular, focused components such as Window Manager, Search Service, or Notification Manager. Android includes two groups of services: system (services such as Window Manager and Notification Manager) and media (services involved in playing and recording media).

Hardware abstraction layer (HAL)

The hardware abstraction layer (HAL) defines a standard interface for hardware vendors to implement and allows Android to be agnostic about lower-level driver implementations. The HAL allows you to implement functionality without affecting or modifying the higher level system. HAL implementations are packaged into modules (.so) file and loaded by the Android system at the appropriate time.
You must implement the corresponding HAL (and driver) for the specific hardware your product provides. HAL implementations are typically built into shared library modules (.so files). Android does not mandate a standard interaction between your HAL implementation and your device drivers, so you have free reign to do what is best for your situation. However, to enable the Android system to correctly interact with your hardware, you must abide by the contract defined in each hardware-specific HAL interface.

Linux Kernel

Android's kernel is based on one of the Linux kernel's long-term support (LTS) branches.
Until version 5.0, Android used Dalvik as a process virtual machine with trace-based just-in-time (JIT) compilation to run Dalvik "dex-code" (Dalvik Executable), which is usually translated from the Java bytecode. Following the trace-based JIT principle, in addition to interpreting the majority of application code, Dalvik performs the compilation and native execution of select frequently executed code segments ("traces") each time an application is launched.Android 4.4 introduced Android Runtime (ART) as a new runtime environment, which uses ahead-of-time (AOT) compilation to entirely compile the application bytecode into machine code upon the installation of an application. In Android 4.4, ART was an experimental feature and not enabled by default; it became the only runtime option in the next major version of Android, 5.0

Various applications based of Android Operating System in Smartphone and outside

1. Manage appointment calendar, to-do list, address book, calculator.

2. Manage and Edit presentations.

3. Video and Phone Conferencing over internet

4. Chat using popular Chat tools (WeChat, WhatsApp etc)

5. Manage your documents using Cloud technology

6. 3g and higher Internet browsing.

7. Google Glasses , TV, Smart Watches, HD Games, Android@Home, Live TV, Emergency Alert applications, read books, fitness applications, medical records and information, shopping through phone, railway/bus booking, airplane booking, check weather and news , educational tools

How can we download updates and Applications on Android Operating System?

Android OS comes with various Mobile Devices. Android OS and billions of apps are available on Google Play store.

What next to expect from Smartphone Market?

Foldable OLED smartphones, Solar powered smartphones, battery taking energy from radio, wifi, dustproof phones, biosensors allowing real time fitness monitor, faster internet, biometric security

4. Eclipse Setup

This Tutorial will be based on Eclipse. Android Studio is the official IDE for Android application development, based on IntelliJ IDEA.

Android IDE - Required Tools, Android Development Tools (ADT), Eclipse, JRE

Download Eclipse from Eclipse website (https://eclipse.org/) Select Version Juno or Indigo

Or download Eclipse Adt Bundle ( Recommended )

Since Eclipse is no longer official IDE for Android Application Development, you will not find links to download Eclipse Adt bundle on android website. You can use below URL's to download Eclipse

Windows 32 bit : https://dl.google.com/android/adt/adt-bundle-windows-x86-20140702.zip

Windows 64 bit : https://dl.google.com/android/adt/adt-bundle-windows-x86_64-20140702.zip

Mac 64: dl.google.com/android/adt/adt-bundle-mac-x86_64-20140702.zip

Linux 86 : dl.google.com/android/adt/adt-bundle-linux-x86-20140702.zip

Linux 64 : dl.google.com/android/adt/adt-bundle-linux-x86_64-20140702.zip

Android Studio Download link : https://developer.android.com/sdk/index.html

Get Offline Android Docs :

API Level 17 : http://dl-ssl.google.com/android/repository/docs-17_r02.zip

API Level 18 : http://dl-ssl.google.com/android/repository/docs-18_r02.zip

API Level 19 : http://dl-ssl.google.com/android/repository/docs-19_r02.zip

API Level 21 (Lollipop) : http://dl-ssl.google.com/android/repository/docs-L_r01.zip

ADT Plugin - https://dl-ssl.google.com/android/eclipse/

Download JRE/JDK before continuing below steps

Once above files are downloaded continue with below steps

You can run Java applications just fine without setting the PATH environment variable.
Set the PATH environment variable if you want to be able to conveniently run the executables (javac.exe, java.exe, javadoc.exe, and so on) from any directory without having to type the full path of the command.

E.g. C:\Program Files (x86)\SqliteBrowser3\bin;

Extract above downloaded Zip file and launch Eclipse.exe from eclipse-IDE\eclipse folder. If you get any errors launching eclipse, search the error on stackoverflow. Most of them will be fixed by modifing eclipse.ini located in same folder as eclipse.exe

Once all errors are resolved, you should see below screen ( this allows you to save your projects in a folder)

If you are using Eclipse without ADT, download ADT Plugin from Google website. Click Help → Install Software

Important step is to configure Android SDK Manager in eclipse. Click on Windows → Preferences and Android Tab and make sure Android SDK Path is set correctly.

Android Toolbar Integration with Eclipse

Toolbar items are : Android SDK Manager ( allows you to download latest SDK's on machine), AVD Manager ( Android Virtual Device Manager - allows you to create and manager all you simulators/virtual devices), Lint tools - allows you to check your projects for errors, New Android Resources to create new android resources in selected project.

Android LogCat

Eclipse → Windows → Show View → Other → Android →LogCat

You can view all logs and errors using this view

Android DDMS perspective for Android Device Monitor

ADT adds DDMS ( Dalvik Device Monitoring Service ) perspective to eclipse. This allows Eclipse to interact your device with Android application program. Select Windows → Open Perspective→Other → DDMS

5. Android Life Cycle

All Android applications run within their own process. Android may choose to end activity to reclaim Needed resources

The application object is created whenever one of your Android components are started. It is started in a new process with a unique ID under a unique user. Even if you do not specify one in your AndroidManifest.xml file, the Android system creates a default object for you. This object provides the following main lifecycle methods:

onCreate() - called before the first components of the application starts

onLowMemory() - called when the Android system requests that the application cleans up memory

onTrimMemory() - called when the Android system requests that the application cleans up memory. This message includes an indicator in which position the application is. For example the constant TRIM_MEMORY_MODERATE indicates that the process is around the middle of the background LRU list; freeing memory can help the system keep other processes running later in the list for better overall performance.

onTerminate() - only for testing, not called in production

onConfigurationChanged() - called whenever the configuration changes

The application object starts before any component and runs at least as long as another component of the application runs.

For more information - Read - http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

Method Purpose
OnCreate() Called then the activity is created. Used to initialize the activity, for example create the user interface.
onResume() Called if the activity get visible again and the user starts interacting with the activity again. Used to initialize fields, register listeners, bind to services, etc
onPause() Called once another activity gets into the foreground. Always called before the activity is not visible anymore. Used to release resources or save application data. For example you unregister listeners, intent receivers, unbind from services or remove system service listeners.
onStop() Called once the activity is no longer visible. Time or CPU intensive shut-down operations, such as writing information to a database should be down in the onStop() method. This method is guaranteed to be called as of API 11.

6. Android Simulator

You can use your Android Phone for testing. To start using your phone for testing

1. Goto your Phone → Settings → Developer options ( some of new phone developer options will not be visible, you need to turn it on)→ Check "USB debugging" option if it's unchecked

2. Goto your phone →Settings →Check "Allow installation of non-Market apps"

3. Goto Eclipse → Windows → SDK Manager ( Install Extras → Google USB Driver to debug using ADB )

If you donot have Android Phone for testing, you can configure new Simulators using AVD Manager

Eclipse → Windows → Android Virtual Device Manager

Click on Create to Create New Virtual Device

Fill all above information and click OK to create new device. Click on launch to start Android Simulator

7. Android SDK Manager

The Android SDK Manager separates the SDK tools, platforms, and other components into packages for easy access and management. You can also customize which sites the SDK Manager checks for new or updated SDK packages and add-on tools.
To access various SDKs and updates you can download them from Google site.

To access SDK Manager Goto Eclipse → Windows → SDK Manager

8. Creating Applications in Android

This section will show creation of new Android Application and various components.

How to Create new Project in Eclipse?

Eclipse → Click New → Other → Select Android Application Project → Click Next

Application Name : Name which is shown in Google Play Store

Project Name : This is only displayed in Eclipse. This name is unique per workspace. Typically you keep this name similar to application Name

Package Name : Package name should be unique identifier for your application. It must rename same for lifetime of your application; allows for updates of your app. This is typically reverse domain name of your organization and other identifiers

Minimum Required SDK : Lowest version of Android that application will support. Common API level is 8

Target SDK : API level that application is tested with

Compile With : Target API

Theme : Choose base theme to use

Click Next

This stpes allows to configure additional information in Android Project

Here you can configure icon which will be displayed in your Android project

You can select default Activity which will be created with this project

You can select Activity Name and Layout Name and Click Finish

Once you click Finish similar directory structure is created as below. If you had made mistake while entering information on above steps. You can later modify them using AndroidManifest.xml and Project Explorer

App Manifest

Every application must have an AndroidManifest.xml file in it's root directory.

The manifest file presents essential information about your app to the Android system, information the system must have before it can run any of the app's code.

Among other things, the manifest does the following:

It names the Java package for the application. The package name serves as a unique identifier for the application.

It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of.

It determines which processes will host application components.

It declares which permissions the application must have in order to access protected parts of the API and interact with other applications.

It also declares the permissions that others are required to have in order to interact with the application's components.

It declares the minimum level of the Android API that the application requires.

For more informatin read - http://developer.android.com/guide/topics/manifest/manifest-intro.html

Structure of Manifest File

8.1 Drawables

A Drawable resource is a general concept for a graphic which can be drawn. The simplest case is a graphical file (bitmap), which would be represented in Android via a BitmapDrawable class.

Every Drawable is stored as individual files in one of the res/drawable folders. Typically you would store bitmaps for different resolutions in the -mdpi, -hdpi, -xhdpi, -xxhdpi subfolders of res/drawable. The ADT project creation wizard creates these folders by default. If these bitmaps are provided in different folder, the Android system selects the correct one automatically based on the device configuration.

If you do not provide bitmaps for all supported resolutions, the Android system scales the closest fit up or down. This is typically undesired as the bitmap might get blury.

In addition to graphical files, Android supports XML drawables and 9-patch graphics. XML drawables are used to describe shapes (color, border, gradient), state, transitions and more.

9-patch graphics are used to define which part of a graphic should be stretched if the view which uses this graphic is larger than the graphic.

More Information : http://developer.android.com/guide/topics/resources/drawable-resource.html

XML Drawables

Shape Drawables : Shape Drawables are XML files which allow to define a geometric object with colors, borders and gradients which can get assigned to Views. The advantage of using XML Shape Drawables is that they automatically adjust to the correct size.

State Drawables : State drawables allow to define states. For each state a different drawable can get assigned to the View. For example the following defines different drawables for a button depending on its state.

Exercise : Create a Shape Drawable which will be used in State Drawable for button click event.

Animation Drawables allows to set animation drawable.

9-Patch Drawables - 9 Patch drawables are Drawables which have a one pixel additional border. On the top and left you define the area which should be scaled if the Drawable is to small for the view. This is the stretch area. For more information visit - http://developer.android.com/tools/help/draw9patch.html

Supporting Multiple Devices : Android runs on a variety of devices that offer different screen sizes and densities.

Screen Size : Represents actual size. For simplicity android groups them into 4 sizes small, normal, large and extra-large.

Screen density : The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen. For simplicity, Android groups all actual screen densities into six generalized densities: low, medium, high, extra-high, extra-extra-high, and extra-extra-extra-high.

Orientation : This is either landscape or portrait, meaning that the screen's aspect ratio is either wide or tall, respectively. Be aware that not only do different devices operate in different orientations by default, but the orientation can change at runtime when the user rotates the device.

Resolution : The total number of physical pixels on a screen. When adding support for multiple screens, applications do not work directly with resolution; applications should be concerned only with screen size and density, as specified by the generalized size and density groups.

Density-independent pixel (dp) : A virtual pixel unit that you should use when defining UI layout, to express layout dimensions or position in a density-independent way. The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities.

Six densities:

1. ldpi (low) ~120dpi

2. mdpi (medium) ~160dpi

3. hdpi (high) ~240dpi

4. xhdpi (extra-high) ~320dpi

5. xxxhdpi (extra-extra-extra-high) ~640dpi

xlarge screens are at least 960dp x 720dp

large screens are at least 640dp x 480dp

normal screens are at least 470dp x 320dp

small screens are at least 426dp x 320dp

Update Android Manifest file to include supports-screens

Best Practices for Drawables :

1. Use wrap_content, fill_parent or dp unit for layout dimension

2. Do not use hard coded pixel values in your application code

3. Do not use AbsoluteLayout

4. Use Size and density-specific resources

5. Test it on multiple simulators


Your app's user interface is everything that the user can see and interact with. Android provides a variety of pre-build UI components such as structured layout objects and UI controls that allow you to build the graphical user interface for your app. Android also provides other UI modules for special interfaces such as dialogs, notifications, and menus.

Every User interface is a subclass of the Android View (android.view.View). Android SDK provides a set of pre-built views that can be used to construct a user interface. e.g. textview, button, progressbar, edittext classes. Such classes are referred as widgets. For requirements that are not met by the widgets supplied with the SDK, new views may be created either by subclassing and extending an existing class, or creating an entirely new component by building directly on top of the View class.
A view can be further grouped to achive various features. E.g RadioGroup can be created which will contain multiple Radio Buttons

All of the views in a window are arranged in a single tree. You can add views either from code or by specifying a tree of views in one or more XML layout files. There are many specialized subclasses of views that act as controls or are capable of displaying text, images, or other content.

Once you have created a tree of views, there are typically a few types of common operations you may wish to perform:

Set properties: for example setting the text of a TextView. The available properties and the methods that set them will vary among the different subclasses of views. Note that properties that are known at build time can be set in the XML layout files.

Set focus: The framework will handled moving focus in response to user input. To force focus to a specific view, call requestFocus().

Set up listeners: Views allow clients to set listeners that will be notified when something interesting happens to the view. For example, all views will let you set a listener to be notified when the view gains or loses focus. You can register such a listener using setOnFocusChangeListener(android.view.View.OnFocusChangeListener). Other view subclasses offer more specialized listeners. For example, a Button exposes a listener to notify clients when the button is clicked.

Set visibility: You can hide or show views using setVisibility(int).

8.3 Layouts

Android SDK Provides set of Views referred as layouts. Layouts are container views

A layout defines the visual structure for a user interface, such as the UI for an activity or app widget. You can declare a layout in two ways:

Declare UI elements in XML : Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.

Instantiate layout elements at runtime : Your application can create View and ViewGroup objects (and manipulate their properties) programmatically.

Load XML Resource : When you compile your application, each XML layout file is compiled into a View resource. You should load the layout resource from your application code, in your Activity.onCreate() callback implementation. Do so by calling setContentView(), passing it the reference to your layout resource in the form of: R.layout.layout_file_name. For example, if your XML layout is saved as main_layout.xml, you would load it for your Activity like so:

LinearyLayout Vs RelativeLayout - http://developer.android.com/guide/topics/ui/declaring-layout.html

Refer http://developer.android.com/guide/topics/ui/declaring-layout.html for detail information on layouts

Sample Layout XML

You can update layout using Graphical Layout as shown below or update using xml.

Exercise 1: Create Simple app using Layout

Exercise 2: Create Set of RadioGroups to take input from user as Gender (M/F) and Country(India/USA/other)

Exercise 3: Use GridLayout to create simple login UserName/Password form

Exercise 4: User MergeLayout to import another layout

8.4 Intent and XML

In order to design apps in Android , you should have basic knowledge of XML. If you want to learn more read this article ( Opens external link ) Introduction to XML Extensible Markup Language - Carol Wolf

Intents are asynchronous messages which allow application components to request functionality from other Android components. Intents allow you to interact with components from the same applications as well as with components contributed by other applications. For example, an activity can start an external activity for taking a picture.

Intents are objects of the android.content.Intent type. Your code can send them to the Android system defining the components you are targeting. For example, via the startActivity() method you can define that the intent should be used to start an activity.

# Start the activity connect to the

# specified class

Intent i = new Intent(this, ActivityTwo.class); startActivity(i);

Types of intents –

An application can define the target component directly in the intent (explicit intent) or ask the Android system to evaluate registered components based on the intent data (implicit intents).

Explicit intents explicitly define the component which should be called by the Android system, by using the Java class as identifier

Implicit intents specify the action which should be performed and optionally data which provides content for the action.

Explicit intents are use for data transfer between activities. Data is passed via instance of Bundle class, which can be retrieved from intent via getExtras() method. Extras are key/value pairs. The key is always of type ‘String’. As value you can use the primitive data types int, float … plus objects of type String, Bundle, Parceable and Serializable.

If you start the activity with the startActivityForResult() method call, you expect feedback from the sub-activity. startActivityForResult(i, REQUEST_CODE);

Exercise 1: Create project with 2 activities and call them using intent

Exercise 2: Create project to share "Hello World" with whatsapp contact

Exercise 3: Create browser app to open website.

How Apps like Facebook, Twitter, Whatsapp or message are looked up in intent list?

You can Achieve this by using in manifest file

The following code will register an Activity for the Intent which is triggered when someone wants to open a webpage

8.5 ListView

This is very common pattern in mobile applications. User sees list of items and scroll though them. User goes through list items and click on list items you start another activity.

ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.

How to achieve scrollable lists in Android .

1. Listview

2. ExpandableListView ( Allows grouping of items )

There are various input types for lists.

Arrays, objects. Most useful is Adaptors (http://developer.android.com/reference/android/widget/Adapter.html)

An Adapter object acts as a bridge between an AdapterView and the underlying data for that view. The Adapter provides access to the data items. The Adapter is also responsible for making a View for each item in the data set.

Adapter class Abstract Class with various methods like getCount(), getItem(), getItemId(),IsEmpty()

An adapter manages the data model and adapts it to the individual entries in the widget. An adapter extends the BaseAdapter class. Adapter are not only used by ListView but other views which extends AdapterView example spinner, GridView, Gallery, StackView

Exercise : Using Listview create list using Adaptors, Create Listview with Single selection, Create ListView with multiple selections.

For more information visit : http://developer.android.com/guide/topics/ui/layout/listview.html

8.6 Fragments

A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity. Interaction with fragments is done through FragmentManager, which can be obtained via Activity.getFragmentManager() and Fragment.getFragmentManager().The Fragment class can be used many ways to achieve a wide variety of results. In its core, it represents a particular operation or interface that is running within a larger Activity. A Fragment is closely tied to the Activity it is in, and can not be used apart from one. Though Fragment defines its own lifecycle, that lifecycle is dependent on its activity: if the activity is stopped, no fragments inside of it can be started; when the activity is destroyed, all fragments will be destroyed.

For more information visit : http://developer.android.com/guide/components/fragments.html

Fragment ViewPager :Layout manager that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view shows.

Exercise : Create Fragment Dialog to display AlertDialog, Create simple Tabbed Fragment, Use Fragment ViewPager to navigate on multiple fragments

8.7 Services

Android Services

What are Services

A service is a component which runs in the background without direct interaction with the user. As the service has no user interface, it is not bound to the lifecycle of an activity.

Services are used for repetitive and potentially long running operations, i.e., Internet downloads, checking for new data, data processing, updating content providers and the like.

Services run with a higher priority than inactive or invisible activities and therefore it is less likely that the Android system terminates them. Services can also be configured to be restarted if they get terminated by the Android system once sufficient system resources are available again.

It is possible to assign services the same priority as foreground activities. In this case it is required to have a visible notification active for the related service. It is frequently used for services which play videos or music.

By default, a service runs in the same process as the main thread of the application. Therefore, you need to use asynchronous processing in the service to perform resource intensive tasks in the background. A commonly used pattern for a service implementation is to create and run a new Thread in the service to perform the processing in the background and then to terminate the service once it has finished the processing. Services which run in the process of the application are sometimes called local services.

They are categorized as Platform Services and Custom Services

The Android platform provides and runs predefined system services and every Android application can use them, given the right permissions. These system services are usually exposed via a specific Manager class. Access to them can be gained via the getSystemService() method. The Context class defines several constants for accessing these services.

An Android application can, in addition to consuming the existing Android platform services, define and use new services. Defining your custom services allows you to design responsive applications. You can fetch the application data via it and once the application is started by the user, it can present fresh data to the user.

For more information visit : http://developer.android.com/guide/components/services.html

8.8 Alerts and Notifications

Scheduling Task with AlarmManager and JobSchedular

Currently in Android we have 2 means of scheduling task


JobSchedular ( Available with API 21 )


The alarm manager is a system service implemented via the AlarmManager class. It can be acquired by the (AlarmManager) getSystemService(Context.ALARM_SERVICE) method call.

The alarm manager is not aware of the current situation of the device, e.g., it does not consider if the device is connected to a power plug, idle or connected to a unmetered network. To Solve this problem Android introduced JobSchedular API in Android 5.0 (API 21 )


The Android 5.0 Lollipop (API 21) release introduces a job scheduler API via the JobScheduler class which allows to batch jobs when the device as more resources available. Jobs which should be scheduled with this API are non user facing jobs, jobs which uploads non time critical user data or downloading non time critical data from the network. In general all things which should be done at some point but are not criotously for the user.

Can JobSchedular work on API level below 21?

No and Yes. It can work with JobSchedularSupport library however there is no gurantee

Compared to a custom SyncAdapter or the alarm manager, the JobScheduler supports batch scheduling of jobs, i.e., as it allows to combine jobs so that thetr battery is not that stressed. JobManager makes handling uploads easier as it handles automatically also the case that the network is unreliable and survives application restarts. Here are example when you would use this job scheduler:

Tasks that should be done once the device is connect to a power supply , Tasks that require network access or a Wi-Fi connection, Task that are not critical or user facing , Tasks that should be running on a regular basis as batch where the timing is not critical

For more information visit : http://developer.android.com/reference/android/app/AlarmManager.html

Android Notifications

Android Notification Manager

Android allows to put notification into the titlebar of your application. The user can expand the notification bar and by selecting the notification the user can trigger another activity. Because notifications can be very annoying, the user can disable notifications for each application. This can be done via the Settings application of the Android device. Select Apps in the Settings, select the app you are interested in and unset the Show notifications checkbox to prevent the app to show notifications. So if user has turned OFF notifications then your app will not be able to see notifications.

Notifications in Android are represented by the Notification class. To create notifications you use the NotificationManager class which can be received from the Context, e.g. an activity or a service, via the getSystemService() method.

For more information visit : http://developer.android.com/guide/topics/ui/notifiers/notifications.html

8.9 Location Services

Android Location API

Lot of mobile apps now a days gives customized experience ( e.g. ola cab ), where they can give you cab's available near by your area by identifiying your GPS location.

Most Android devices allow to determine the current geolocation. This can be done via a GPS (Global Positioning System) module, via cell tower triangulation or via wifi networks. Android contains the android.location package which provides the API to determine the current geo position.

The LocationProvider class is the superclass of the different location providers which deliver the information about the current location. This information is stored in the Location class.

LocationProvider → Network → Uses the mobile-network or wifi to determine best location

LocationProvider → gps → USES GPS receiver in Android Devices to determine best location via satellites. More precise compare to network

Testing in emulator → The Google Map activity should automatically activate the GPS device in the emulator but if you want to use the location manager directly you need to do this yourself. ou can use the "DDMS" Perspective of Eclipse to send your geoposition to the emulator or a connected device. For open this Perspective select Window → Open Perspective → Other... → DDMS. In the Emulator Control part you can enter the geocoordinates and press the Send button. Or use telnet localhost 5554 geo fix 13.24 52.31

Fore more information read : https://developer.android.com/training/location/index.html

Android Location API

In Order to run programs with Google Maps you need Google API, download it from Android SDK Manager

8.10 Google Maps

Google Maps Android API v2

In Order to run programs with Google Maps you need Google API. Google provides via Google play a library for using Google Maps in your application. The following description is based on the Google Maps Android API v2 which provides significant improvements to the older API version. Ensure you create an Google API based emulator. This emulator can also be used to test Google map and other Google Play Service integration.

Google Play Services and Google Map Integration https://developers.google.com/maps/documentation/android/start?hl=en

Google Play Services and Google Map Integration

Google downloads project to sdk/extras/google/google_play_services/libproject/google-play-services_lib

Import Library to workspace using import project

To use Google Maps you need to create a valid Google Maps API key. The key is free, you can use it with any of your applications that call the Maps API, and it supports an unlimited number of users.

You get this key via the Google APIs Console. . You have to provide your application signature key and the application package name

The Eclipse debug key for signing your application can be found in the userhome/.android/debug.keystore file.To create the SHA-1 for your debug keystore you use the keytool command from your JDK installation pointing to the debug.keystore file.

For more information visit - https://developers.google.com/maps/documentation/android-api/

8.11 Audio and Video

Android provides two main API's for playing sounds. The first one via the SoundPool class and the other one via the MediaPlayer class

The android.media.MediaRecorder class can be used to record audio and video. To use MediaRecorder you need to set the source device and the format

List of Supported Media Formats : http://developer.android.com/guide/appendix/media-formats.html

8.12 JSON Parsers

Java Script Object Notation

JSON is syntax for storing and exchanging data.

JSON is easier-to-use alternative to XML.

It is used in webservices. Earlier WebServices used XML to transmit data however JSON is preferred format because it is more lightweight

Understand REST Webservices https://docs.oracle.com/javaee/6/tutorial/doc/gijqy.html

It’s used in various languages like in JavaScript you can simply parse JSON using JSON.parse(result)

Understand JSON - http://www.secretgeek.net/json_3mins

Understand JSON - https://developer.yahoo.com/javascript/json.html

Understand JSON - https://json-csv.com/

Android platform includes json.org libraries which allows working with JSON files. But you can use other solutions for parsing JSON files.

For more information read : http://developer.android.com/reference/org/json/JSONObject.html

8.13 Android Sensors and Gestures

Android supports gestures. To use this support your application must use the view "GestureOverlayView". In this view you place your other views. Gestures are defined by a binary resources which can be created with an example program from the Android SDK. In your activity you can load Gestures via GestureLib.fromRawResource(). If a gesture is detected then the method "onGesturePerformedListener" is called. For this the activity must implement the interface "OnGesturePerformedListener" and must register itself at the GestureOverlayView with the method "addOnGesturePerformedListener()".

In below example sensors made app very succesful. Traditional navigation buttons would have not made app such big hit

Android shows the gestures in yellow for recognized gestures and a ligher yellow for not recognized gestures. You can turn this off, via setGestureColor(Color.TRANSPARENT) or setUncertainGestureColor(Color.TRANSPARENT) on the GestureOverlayView.

Unfortunately GestureOverlayView doesn’t work with Layout Framework. Bug - https://code.google.com/p/android/issues/detail?id=13686

For more information read : http://developer.android.com/guide/topics/sensors/sensors_overview.html

For more information read : http://developer.android.com/training/gestures/index.html

8.14 Action Bars

Android projects consist of multiple navigations, multiple screens. In order to help them navigate there are various way we can allow, via menus, or action bars.

The action bar (ActionBar) is located at the top of the activity. It can display the activity title, icon, actions which can be triggered, additional views and other interactive items. It can also be used for navigation in your application.

The action bar is enabled for devices which specify a target SDK of API version 11 or higher. It is possible to disable the action bar via the used theme, but the default Android themes have it enabled.

The action bar has been introduced in Android 3.0. If you want to use the action bar on devices with an earlier Android release, you have two popular options.

ActionBar Sherlock (http://actionbarsherlock.com)

Use the ActionBarCompat library from the Android support library v7, which supports the action bar as of Android 2.1. (http://developer.android.com/tools/support-library/setup.html)

Entries in Action Bar are typically called as Actions, You can create Actions via code or via XML. Each Menu file is stored in res/Menu folder with different name.

An Activity adds entry using OnCreateOptionsMenu() method.

android:showAsAction="always“ helps to decide visibility of Action Bar. You can set it to various options like ifRoom

MenuInflator class allows to inflate menu.xml inside activity.

OnOptionsItemSelected() allows to identify click event

If you want to refresh menuitem() call invalidateMenuOptions() method.

SetTitle, SetSubtitle – set’s title of menu

Menu Background Image / Colour can be set using SetBackgroundDrawable() , Android 4.2 and above you can use AnimationDrawable to animate Menu

Fragments can be used with Action bar for navigation.

For more information Read : http://developer.android.com/guide/topics/ui/actionbar.html

8.15 Options Menus

Menus are a common user interface component in many types of applications. To provide a familiar and consistent user experience, you should use the Menu APIs to present user actions and other options in your activities.

Beginning with Android 3.0 (API level 11), Android-powered devices are no longer required to provide a dedicated Menu button. With this change, Android apps should migrate away from a dependence on the traditional 6-item menu panel and instead provide an action bar to present common user actions.

Three fundamental types of menus or action presentations on all versions of Android:

Options menu and action bar The options menu is the primary collection of menu items for an activity. It's where you should place actions that have a global impact on the app, such as "Search," "Compose email," and "Settings."

Context menu and contextual action mode A context menu is a floating menu that appears when the user performs a long-click on an element. It provides actions that affect the selected content or context frame.

Popup menu A popup menu displays a list of items in a vertical list that's anchored to the view that invoked the menu.

Fore more information read : http://developer.android.com/guide/topics/ui/menus.html

8.16 Options Menus

Styles and Themes


Android allow you to define the look and feel, for example colors and fonts, of Android components in XML resource files. This way you have to set common style attributes only once in one central place.

If the entry in the resource file is used to style a view, it is typically referred to as a style, while if it is used for styling an activity or application it is typically called a theme .

To define a style or a theme, save an XML file in the /res/values directory of your project. The root node of the XML file must be and you use a style tag that includes the name attribute. This tag contains than more or more item tags which define values for named attributes.

Styles (and themes) support inheritance by using the parent attribute of the style tag. This way the style inherits all settings from the parent style and can overwrite selected attributes.

You can assign styles using style attribute style=”@style/text“


A theme is a style applied to an entire activity or application, rather than an individual View (as in the example above). The technique of defining a theme is the same as defining a style.

As of API 14 and before API 21 the holo design can be used

As of API 21 the material design is the new default design you should be used
@android:style/Theme.Material (dark version)
@android:style/Theme.Material.Light (light version)

The v7 Support Libraries provide themes with material design styles for some widgets. This allows you to use material design on earlier releases.

8.17 SQLite and Content Providers

Sqlite ( www.sqlite.org )


SQLite is an Open Source database. SQLite supports standard relational database features like SQL syntax, transactions and prepared statements. The database requires limited memory at runtime (approx. 250 KByte) which makes it a good candidate from being embedded into other runtimes.

SQLite supports the data types TEXT (similar to String in Java), INTEGER (similar to long in Java) and REAL (similar to double in Java). All other types must be converted into one of these fields before getting saved in the database. SQLite itself does not validate if the types written to the columns are actually of the defined type, e.g. you can write an integer into a string column and vice versa.

SQLite in Android

SQLite is embedded into every Android device. Using an SQLite database in Android does not require a setup procedure or administration of the database. You only have to define the SQL statements for creating and updating the database. Afterwards the database is automatically managed for you by the Android platform. If your application creates a database, this database is by default saved in the directory DATA/data/APP_NAME/databases/FILENAME

The android.database package contains all necessary classes for working with databases. The android.database.sqlite package contains the SQLite specific classes.

To create and upgrade a database in your Android application you create a subclass of the SQLiteOpenHelper class. In the constructor of your subclass you call the super() method of SQLiteOpenHelper, specifying the database name and the current database version.

In this class you need to override the following methods to create and update your database.

onCreate() - is called by the framework, if the database is accessed but not yet created.

onUpgrade() - called, if the database version is increased in your application code. This method allows you to update an existing database schema or to drop the existing database and recreate it via the onCreate() method.

The SQLiteOpenHelper class provides the getReadableDatabase() and getWriteableDatabase() methods to get access to an SQLiteDatabase object; either in read or write mode.


SQLiteDatabase is the base class for working with a SQLite database in Android and provides methods to open, query, update and close the database

It provides insert(), update() and delete() methods

A query returns a Cursor object. A Cursor represents the result of a query and basically points to one row of the query result. This way Android can buffer the query results efficiently; as it does not have to load all data into memory.

Content provider and sharing data

If you want to share data with other applications you can use a content provider (short provider). Provider offer data encapsulation based on URI's. Any URI which starts with content:// points to a resources which can be accessed via a provider. A URI for a resource may allow to perform the basic CRUD operations (Create, Read, Update, Delete) on the resource via the content provider.

A provider allows applications to access data. The data can be stored in an SQlite database, on the file system, in flat files or on a remote server.

While a content provider can be used within an application to access data, its is typically used to share data with other application. As application data is by default private, a content provider is a convenient to share you data with other application based on a structured interface

A content provider must be declared in the manifest file for the application.

To create your custom content provider you have to define a class which extends android.content.ContentProvider. You must declare this class as content provider in the Android manifest file. The corresponding entry must specify the android:authorities attribute which allows identifying the content provider. This authority is the basis for the URI to access data and must be unique.

8.18 File Storage

Android allows to persists application data via the file system. For each application the Android system creates a data/data/[application package] directory.

Android Supports following ways of storing data in local file system

Files – You can create and update files

Preferences – Android Allows you to save and retrieve persistant key-value pairs of primitive data type.

SQLite Database – Instances of SQLite databases are also stored in local file system.

Files are stored in files folder, Preferences are stored as XML files in the shared_prefs folder, SQLite databases are stored under databases folder. Android Files can be accessed using standard java.io classes

For Security Android only allows applications to write into application directory. It can create additional sub-directories in application directory. Application can grant read or write permissions for other applications.

Android:installLocation : preferedExternal or Auto android.permission.READ_EXTERNAL_STORAGE

SharedPreferences are stored in WeakHashMap so listener may be recycled if code doesn’t hold reference to it. This is last of 3 options recommended. E.g. of SharedPreferences are app settings.

9 Deployment and Other Information

9.1 Common Android Development Problems

1. Runtime Linking Errors (Libraries linking issue) - Lot of time your project get's compiled without any issue but fails at execution. There might be linking issue which you need to resolve.

If you are using external libraries, make sure they are referred correctly ( Right click Project → Properties)

2. .R file not found - Solution is to Rebuild your project. Make sure there are no compilations errors. Delete Bin and Gen folder and build project again

3. New Changes doesn’t reflected in build - Sometimes UI changes are not reflected in build. Solution to this problem is rebuild.

4. Application Crashes with ActivityNotFoundException - If Activity is not defined in AndroidManifest.xml, project compiles without any issue but fails at runtime with ActivityNotFoundException. Make sure all activites are defined correctly in AndroidManifest.xml

5. Emulator not showing for testing - Sometimes you need to restart ADB to get device/emulator listed. Command is adb kill-server and adb start-server

6. LogCat not displayed correctly - Restart Eclipse or ADB

7. UI alignment issues on Various phones - Make sure layout is correct without any hardcoded values.

8. Timeout during app deployment on simulator - Increase ADB Connection time out in DDMS

9.2 Hybrid App Development

Using Eclipse you are developing Native apps. There are various tools available which allow you to create apps using HTML5 ( hybrid app ). Below is list of some of apps which are available in market ( PS - most of them are paid commercial apps.)


2. Mobile Angular UI

3. Intel XDK

4. Appcelerator Titanium

5. Sencha touch

6. Kendo UI

7. PhoneGap

8. App.js

9.3 Deployment on Google Market

Before understanding Google Play store process. First you need to create a .apk file which can be uploaded on Google Play Store

Click on File and Export

Select Android And Export Android Application

Follow Instructions on each step to create .apk file. Use Existing keystore file or use new one. Make sure to keep keystore file as it's required to create updates.

Once apk file is generated and tested, follow below steps to upload your apk file on Google Play Store

Android Play Store Setup

Login to Google Play Store developer console. URL - https://play.google.com/apps/publish/

Register with your gmail ID and pay one time fee of $ 25

Click on "Add New Application" on top right Corner

On Store Listing you can show images, description of store etc

On APK Page you can upload your APK files ( Upload updates only with incremental version number)

Submit Content Rating based on your app

Select App availibility / pricing etc.

Add In-app products and pricing if any

Once all above information is entered , hit submit on top right and your app will be availble in market after 7-8 hours of submission.

9.4 Various Tools and Libraries

1. MAT (Eclipse Memory Analyzer Tool ) https://eclipse.org/mat/

2. 9-patch Tool to create 9-patch Images

3. MonkeyRunner – automate testing

4. Proguard

5. Logcat

6. https://romannurik.github.io/AndroidAssetStudio/index.html - Create Launcher Icons, Action bar icons, Tons of stuff

7. Github

8. Stackoverflow

9. SqliteBrowser

10. DroidDraw - www.droiddraw.org

11. DDMS

12. AVD Manager , The Hierarchy Viewer ( Eclipse ),TraceView , Lint, Memory Dumps, profile GPU rendering

9.5 Proguard

ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods using short meaningless names. Finally, it preverifies the processed code for Java 6 or higher, or for Java Micro Edition.

Some uses of ProGuard are:

Creating more compact code, for smaller code archives, faster transfer across networks, faster loading, and smaller memory footprints.

Making programs and libraries harder to reverse-engineer.

Listing dead code, so it can be removed from the source code.

Retargeting and preverifying existing class files for Java 6 or higher, to take full advantage of their faster class loading.

ProGuard's main advantage compared to other Java obfuscators is probably its compact template-based configuration. A few intuitive command line options or a simple configuration file are usually sufficient. The user manual explains all available options and shows examples of this powerful configuration style

ProGuard is fast. It only takes seconds to process programs and libraries of several megabytes. The results section presents actual figures for a number of applications

Update project.properties to point to proguard.config=${sdk.dir}/tools/proguard/proguard-android-projectName.txt

9.6 Testing in Android

1. https://developer.android.com/tools/testing/testing-tools.html

2. Junit Test Cases

3. Android Test Framework

4. Mockito http://mockito.org/

5. AndroidJUnitRunner: JUnit 4-compatible test runner for Android

6. Espresso: UI testing framework; suitable for functional UI testing within an app

7. UI Automator: UI testing framework; suitable for cross-app functional UI testing across system and installed apps

8. Monkey Runner

9. Hamcrest https://code.google.com/p/hamcrest/

10. AssertJ assertions https://github.com/square/assertj-android

11. Robotium https://code.google.com/p/robotium/

12. Github

9.7 Development with Android Studio


Android Studio is the official IDE for Android application development, based on IntelliJ IDEA. On top of the capabilities you expect from IntelliJ, Android Studio offers:

1. Flexible Gradle-based build system

2. Build variants and multiple apk file generation

3. Code templates to help you build common app features

4. Rich layout editor with support for drag and drop theme editing

5. lint tools to catch performance, usability, version compatibility, and other problems

6. ProGuard and app-signing capabilities

7. Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine

10 Using This Tutorial

This Tutorial gives basic overview of Android App development from coding to deployment, what it doesn't include is examples in detail and detail walkthrough of each section. This Tutorial should be used as head start for Android Development. For business inquiry send us an email @ contactus@rachittechnology.com

You are FREE to use content:
1. In digital format on websites, blog posts, social media, advertisements, film and television productions, web and mobile applications.
2. In printed materials such as magazines, newspapers, books, brochures, flyers, product packaging.
3. Or personal use
Provided you give credits to Rachit Technology.

Image Credits and Content: Images and content used in this tutorial are from Wikipedia and developer.android.com.