getting started with android application development [indicthreads mobile application development...

73
1 Android Basics Rohit Ghatol QuickOffice & Synerzip

Upload: indicthreads

Post on 16-Apr-2017

3.541 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

1

Android Basics Rohit GhatolQuickOffice & Synerzip

Page 2: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

2

About MeName: Rohit GhatolOccupation:

1. Architect @QuickOffice2. Project Mgr @Synerzip3. Certified Scrum Master

Thinks I like to do:1. Talk at Technical Platforms2. Agile Evangelism3. Motivational Speaker and Trainer

LinkedIn ProfileLinkedIn Profile

Page 3: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

3

TopicsIntroduction to AndroidAndroid OS CapabilitiesBuilding Blocks of AndroidUnderstanding HelloWorldUse Case – Building Blocks in Gmail ClientUnderstanding Android UIReferences & Further Reading

Page 4: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

4

Introduction to Android• Software stack for mobile devices

that includes• an operating system• middleware• key applications• SDK to develop application

Page 5: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

5

Introduction to Android

Page 6: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

6

Introduction to Android• About Android Applications

• Written in Java• Compiled to .dex • Run in Dalvik VM• Packaged and Shipped as APK

Page 7: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

7

Introduction to Android• About Dalvik VM

• Cut from Apache Harmony Project• Device can run multiple VMs efficiently• Executes Dalvik Executable (.dex) -

optimized for minimal memory footprint• Watch Video – Dalvik VM Internals

Page 8: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

8

More about Applications

Dalvik VM

Linux Process

Linux Kernel

Process Process Process

DalvikVM

DalvikVM

DalvikVM

Uid 1 Uid 2 Uid 3data

data

com.xyz.email

com.abc.skype

com.koko.sukudo

shared_prefs

files

databases

. . . . . .

. . . . . .

UID 1

UID 2

UID 3

Page 9: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

9

Android VersionsOS Version

Nickname API Level Date Comments

1.1 __ 2 February 2009

1.5 Cupcake 3 30 April 2009 Based on Linux Kernel 2.6.27

1.6 Donut 4 5 September 2009

Based on Linux Kernel 2.6.29

2.1 Eclair 7 26 October 2009 

Based on Linux Kernel 2.6.29

2.2  Froyo 8 20 May 2010 Based on Linux Kernel 2.6.32

2.3 Gingerbread Q4 20103.0 Based on Linux Kernel 2.6.33 or .34

3.0 Honeycomb early 2011

Page 10: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

10

Android OS CapabilitiesFeatures• Phone and OS features

• 3G, GPS, Accelerometer, SQLite, Camera, Telephony, Webkit, etc

• Reuse of Data• Reuse of Functionality

Page 11: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

11

Android Phone DemoBefore anything you must see what an Android

Phone looks like!1.Desktop2.Notification Bar3.Contact Manager4.Gmail Application

Page 12: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

12

Reuse of DataDefault Contact

ManagerNew Contact

Manager

Replaces

What happens to data feed into the default Contact Manager?

Page 13: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

13

Reuse of DataDefault Contact

ManagerNew Contact

Manager

Replaces

Content Provider

But Uses

Page 14: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

14

Reuse of FunctionalitySudoko Game New Requirement

Share with Friends using1.SMS2.Email

Time to learn SMS API and Email API and code them into my application!

More code! Hee hee

Page 15: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

15

Reuse of FunctionalitySudoko Game

SMS

Mail

SMS

Mail

Intention: Want to send Email

Here are two applications who can do it for you.

Page 16: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

16

Reuse of FunctionalitySudoko Game

SMS

Mail

SMS

Mail

Intention: Want to send Email

Page 17: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

17

Building Blocks of Android

Activity(Screen)

Service(Background)

BroadcastReceiver

(respond to events)

Content Provider

(Database/Directory)

Notification Manager

......

Alarm Manager

Read more - http://developer.android.com/guide/topics/fundamentals.html

Page 18: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

18

Environment Setup

Page 19: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

19

Environment Setup

Page 20: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

20

Environment Setup

Text

Page 21: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

21

Text

Environment Setup

Page 22: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

22

Simple HelloWorld

Text

Page 23: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

23

Simple HelloWorld

Text

Page 24: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

24

Simple HelloWorld

Text

Page 25: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

25

Simple HelloWorld

Text

Page 26: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

26

Simple HelloWorld

Text

Page 27: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

27

Simple HelloWorld

Text

Page 28: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

28

Simple HelloWorld

Text

Page 29: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

29

Simple HelloWorld

Text

Page 30: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

30

Simple HelloWorld

Text

Page 31: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

31

Simple HelloWorld

Text

Page 32: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

32

Simple HelloWorld

Text

Page 33: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

33

Simple HelloWorld

Text

Page 34: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

34

Simple HelloWorld

Text

Page 35: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

35

Simple HelloWorld

Text

Page 36: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

36

Simple HelloWorld

Text

Page 37: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

37

Simple HelloWorld

Text

Page 38: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

38

Simple HelloWorld

Text

Page 39: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

39

Simple HelloWorld

Text

Page 40: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

40

Building Application .

You need a Screen (Activity)Views could be• Buttons• Text Views• etc ….

Layouts could be• Linear Layout• Relative Layout• Table Layout• etc …..

Page 41: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

41

Building Block - Activity

Activity Life Cycle

Page 42: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

42

ForegroundLifeCycleVisible

LifeCycleComplete LifeCycle

Building Block - Activity

Activity Life Cycle made easieronCreate

onDestroy

onStart

onStop

onResume

onPause

Page 43: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

43

Building Block - Activity

What to do in each life cycle methods?onCreate

onDestroy

onStart

onStop

onResume

onPause

Page 44: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

44

Building Block - Service

ServiceLifeCycle

Page 45: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

45

Building Block – Broadcast Receiver1. Broadcast Receiver is more of a Call

back2. Android will call your Broadcast

receiver depending on the intent filter

Page 46: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

46

Building Block – Content Provider1. Content Provider are more of RestFul

like exposed Database2. They are accessed using Content

Resolver3. They can allow full CRUD Operations

on them (Any application can add/delete/edit contacts in Phone’s Contact Manager)

Page 47: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

47

Building Block – Intents

Need• Class Name

Need • ACTION• CATEGORY• DATA

Page 48: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

48

Building Block – Intents<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sample“ android:versionCode="1“ android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloWorld" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="4" /></manifest>

Program launcher shows all the activities which have MAIN Action and LAUNCHER category

Page 49: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

49

Building Application .So what happens two activities have the exact same intent filter and an intent is fired.

Simple you choose one application, and you have an option to tell to se that application as the default application hence forth

Page 50: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

50

Building Application .

Intent to launch an Activity

• Context.startActivity(intent)

• ContextstartActivityForResult(intent)

Intent to launch an Service

• Context.startService(intent)

Intent to send a broadcast

• Context.sendBroadCast(intent)

Using Intents

Page 51: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

51

Building Block – Permissions<manifest

xmlns:android="http://schemas.android.com/apk/res/android package="com.android.app.myapp" > ……………………………………………………………..<uses-permission android:name="android.permission.RECEIVE_SMS" />

</manifest>

Page 52: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

52

Understanding Android UI

• Lets Draw the Screen using Linear Layouts

Current Playlist

Player

Page 53: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

53

Understanding Android UI

• Lets Draw the Screen using Linear Layouts

Current Music InfoProgress Bar

Buttons

Music file 1

Music file 2

Music file 3

Music file 4

Page 54: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

54

Understanding Android UI

• Lets Draw the Screen using Linear Layouts

Current Music InfoProgress Bar

Music file 1

Music file 2

Music file 3

Music file 4

Prev NextPlay

Page 55: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

55

Layout XML

………………………….

………………………….

Page 56: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

56

Understanding Android UI

• Lets Draw the Screen using Relative Layouts

Beautiful World

Take That

Title is aligned to the top and right of the image

Author is aligned to the bottom and right of the

image

Page 57: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

57

Layout XML

Page 58: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

58

Understanding Android UI

Use LayoutsLayouts can be defined in different XML

filesCode can refer to these layout xml files

Page 59: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

59

Gmail Application – Use Case

Page 60: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

60

Building Blocks of Android

Activity Service BroadcastReceiver

Content Provider/SQL ite

Database

Gmail Sync Data Store(Email List)

Phone Boots

Communication is using Intents

Page 61: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

61

Activity

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Notifi. M..

Phone Boots

Page 62: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

62

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

Page 63: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

63

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

Page 64: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

64

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

starts

Page 65: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

65

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

Completes

Page 66: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

66

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

Stores

Page 67: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

67

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

Stores

Gmail Notification

Page 68: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

68

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

Gmail Notification

Page 69: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

69

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

Gmail Notification

Page 70: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

70

Gmail Sync

ServicePhone Boots

Broadcast R

Data Store(Email List)

Database

Events..

Alarm M..

Phone Boots

GmailSync (5 mins)

Activity

Notifi. M..

Gmail Notification

Page 71: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

71

References & Further Reading1. What is Android?2. Android Fundamentals3. Notepad Guided Tutorial4. Common Tasks?5. Articles and Docs6. Best Practices - Performance

Page 72: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

72

Youtube Videos - Android

http://www.youtube.com/user/GoogleDevelopers#g/c/316B437F0CB82A68

Page 73: Getting Started With Android Application Development  [IndicThreads Mobile Application Development Conference]

73

Reach Me1. Linked In2. Email – [email protected]