Android app devolopment

Preview:

Citation preview

By-

SitCom Solutions

AN INTRODUCTION TO

ANDROID APP DEVOLOPMENT

Overview• What we will cover ?

What is android?

Setting up Development Environment

Project Structure

Activity

UI and Layouts

Services

Broadcast Receivers

Deployment 1st Phase

Introduction

Android Background

Android Architecture

Android Applications

APIs

Security and Permissions

The Android Market

Android Background• Mobile Operating System developed by Android Inc

Google bought in 2005

• Based on Linux Kernel

• Open Source

• Built on Idea of being open

All applications are equal

Everything is swappable

• Application Layer is Java

• Has built in Google Market for Applications

• The first commercially available Smartphone running Android was the HTC Dream, released on October 22, 2008

• Source Code released under Open Source

Android Background• Supports a multitude of

devices

• Growth Rate since it entered into mobile world

Android Architecture

Android Architecture• Linux Kernel

• Libraries

Android Architecture• Application Framework

• Applications

Android Applications• Loosely coupled set of Service

• Contains

• Activities

• Services

• Broadcast Receivers

• Content Provider

• Can use other applications if

required

• Written in Java.

• Implements the “principle of least privilege”

APIs• Android API level corresponds to particular Android OS

version

Other APIs

Location

Services

Telephony

Google Maps

Audio and

Video

Security and Permissions

• Each application is provided a unique Linux User ID

• Each App lives in its Security Sandbox

• Each App has access to privileges required by it

• Apps needs to take permissions to access end user

facilities required by an application

• Applications can share resources and data through

Intents.

The Android Market

•Direct access from phone and web•Open

•No approval•Not Policed

•Other markets also available•Cost

•One time 25$ fees to be an android developer•30% of cost at which application is sold

Setting Up Development Environment

• You can develop on different OS using different IDE’s.

Setting Up Development Environment

• Long Way so First things first

• IDE

• Download an IDE say Eclipse

• Go to www.Eclipse.org and select download for Java environment

• Extract it to a folder in C:\ with a name of your choice

• JDK and JRE

• Download Java Development Kit and Java Runtime Environment

• Install and Create Environment variables for java compilation.

Setting Up Development Environment

• Download Android SDK

• Go to http://developer.android.com/sdk/installing/index.html

• Run SDK manager from root folder and install all packages you require to develop for.

• Download and install ADT fro IDE here Eclipse

• Open Eclipse-> Click on Help-> Click on Install new Software

• On next popup Window click on->ADD

• Type a name Android and URL-https://dlssl.google.com/android/eclipse/

• On next window select all to install and click->Next

• Configure ADT

• Click on Window->Preferences

• Now select Android from Left Panel and browse sdk location from right to place where you downloaded android sdk.

Setting Up Development Environment

Let’s Create an Android Project• To do this Open Eclipse or your IDE and click on File-

>New->Other/Android Project

• If Other than select from popup window Android Project

Let’s Create an Android Project• Next select activity for your app and an icon.

First Page

Project Structure

Android Manifest File• Must be available to all apps in root directory.

• Describes all Components of an Application

• Activities

• Permissions

• Services

• Data

• Intent Filter

• Application

• SDK version

• And many more to explore

Activities

• Backbone

• Main Entrance when started is Main Activity

• Sub Class of Activity class

• Activity state preserved in “Back Stack”

Activities Lifecycle

Activities -What we can do with it?

• Create Views

• Get and Update Views

• Respond to View Events using “Intents”

• Create and Launch Activities

• Save Activity State

• Control how our Application responds.

• We can add “Fragments” to Activities.

Views and Layouts ! What are these?

• Everything in android UI is a View because-

• View is an overloaded word

• Layouts

• Android Widgets

• UI

• Pass object to Activity and

it draws for us

• View Object

• XML Layout File

Layouts• XML representation of View Objects

• Are typically ViewGroups

• Linear Layout

• Relative Layout

• Table Layout

• Absolute Layout

• Other Layouts

• List Views

• Grid Views

• Tab View

• And lot more to Explore

Services• Runs in background, No UI

• Two Types

• Bound (runs till activity lives)

• Unbound (runs indefinitely)

• Service Lifecycle

Broadcast Receivers• Responds to System Wide Broadcast announcements

• Can be

• Static

• Dynamic

• Some System Broadcasts are

• Low Battery notification

• Memory Full etc.

Deployment• Sign your Application with your Private key

• Right Click on Project

• Go to Android Tools->Export Signed Application

• Fill the details

• Obfuscate with Proguard

• In order to diminish the misuse of your code use it.

• Open Source Java Tool in ADT

• Prevents code to be meaningfully Decompiled.

• Just add a line in default.properties

• Proguard.Config=proguard.cfg

• Export from Eclipse or other IDE

• And you are with a “.apk” file.