getting started with android development
DESCRIPTION
Getting Started with Android Development. Rohit Ghatol. About Me. Rohit Ghatol Architect @QuickOffice Project Mgr @Synerzip Certified Scrum Master Author “ Beginning PhoneGap ” @Apress Founder TechNext Pune (Pune Developer Community). LinkedIn Profile. Topics. Understanding Android - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/1.jpg)
Getting Started with Android Development
Rohit Ghatol
![Page 2: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/2.jpg)
About MeRohit Ghatol
1. Architect @QuickOffice2. Project Mgr @Synerzip3. Certified Scrum Master4. Author “Beginning PhoneGap” @Apress5. Founder TechNext Pune (Pune Developer
Community)
LinkedIn ProfileLinkedIn Profile
![Page 3: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/3.jpg)
Topics
• Understanding Android• Android Building Blocks• Putting Building Blocks Together• Latest things in Android World• Reference Material
3
![Page 4: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/4.jpg)
Understanding Android
4
![Page 5: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/5.jpg)
What is Android?
• Software stack for mobile devices that includes• an operating system• middleware• key applications• SDK to develop application
5
![Page 6: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/6.jpg)
Android Architecture
6
![Page 7: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/7.jpg)
Android OS Names
7
![Page 8: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/8.jpg)
8
OS Version
Nickname API Level Date
1.1 __ 2 9th February 2009
1.5 Cupcake 3 30 April 2009
1.6 Donut 4 5 September 2009
2.1 Eclair 7 26 October 2009
2.2 Froyo 8 20 May 2010
2.3 Gingerbread 9 6th December 2010
3.0 Honeycomb 11 22nd February 2011
4.X Icecream Sandwich
14 19th October 2011
http://en.wikipedia.org/wiki/Android_version_history
![Page 9: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/9.jpg)
Key OS Capabilities
9
![Page 10: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/10.jpg)
Android OS Capabilities
• Phone and OS features– 3G/4G,GPS, Accelerometer, Compass, Camera,
SQLite, Wifi, Bluetooth, etc– Near Field Communication– Cloud to Device Messaging (C2DM)– Direct Wifi
![Page 11: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/11.jpg)
Android OS Capabilities
• Notable Features of Android– All Applications are equal– Reuse of Data– Reuse of Functionality
![Page 12: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/12.jpg)
All Applications are Equal
• Replace Home Application• Replace Contacts, Dialer Applications• Replace SMS, Email Applications• Replace Settings Application• OEM Customizations (e.g HTC Sense)
12
![Page 13: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/13.jpg)
Reuse of DataDefault Contact Manager
Replaces
What happens to data feed into the default Contact Manager?
New Contact Manager
![Page 14: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/14.jpg)
Reuse of DataDefault Contact Manager
Replaces
New Contact Manager
Content Provider
But Uses
“Replaces” means by default the new app is launched, but old app still exists
![Page 15: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/15.jpg)
Reuse of FunctionalityNew RequirementShare with Friends using1.SMS2.Email
Time to learn SMS API and Email API and code them into my application!
More code! Hee hee
My Coupons
![Page 16: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/16.jpg)
Reuse of FunctionalitySMS
Intention: Want to send Email
Here are two applications who can do it for you?
My Coupons
![Page 17: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/17.jpg)
Reuse of FunctionalitySMS
My Coupons
![Page 18: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/18.jpg)
Reuse of FunctionalitySMS
My Coupons
![Page 19: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/19.jpg)
Android Environment Setup
http://developer.android.com/sdk/installing.html
19
![Page 20: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/20.jpg)
20
Android SDKEclipse
ADT
Android …..
……………….
Android 3.2
Android 4.x
Android 2.2
Google API 2.2
SDK Manager
AVD Manager
Manages
Emulator Emulator
![Page 21: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/21.jpg)
Android Application
Dex FileAndroid Manifest Resources
MyApp.apk
Signed by Self Signed Private Key
![Page 22: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/22.jpg)
Identity of Android Application
22
Identity Part Example
Package Name com.sparklytix.android.app.twitter
versionCode 1 (numeric value 2,3,4,..101,102)
Private Key
![Page 23: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/23.jpg)
Android Build Cycle
23
.java .apk.dex.class
javac dx
apt
• AndroidManifest.xml• resources
![Page 24: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/24.jpg)
How Applications behave?
24
![Page 25: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/25.jpg)
25
Linux Kernel
Process Process Process
DalvikVM
DalvikVM
DalvikVM
Uid 1 Uid 2 Uid 3 data
data
com.xyz.email
com.abc.skype
com.koko.sukudo
shared_prefs
files
databases
. . . . . .
. . . . . .
UID 1
UID 2
UID 3
![Page 26: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/26.jpg)
Android Building Blocks
26
![Page 27: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/27.jpg)
Read more - http://developer.android.com/guide/topics/fundamentals.html
Activity Service Broadcast Receiver
Alarm Manager
Noti-fication
Manager
Content Provider
Intents
Content Resolver
Building Blocks
Other Components……
![Page 28: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/28.jpg)
First Android Application
28
![Page 29: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/29.jpg)
29
![Page 30: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/30.jpg)
30
![Page 31: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/31.jpg)
31
![Page 32: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/32.jpg)
32
![Page 33: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/33.jpg)
33
![Page 34: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/34.jpg)
34
![Page 35: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/35.jpg)
Interacting with Buttons
35
![Page 36: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/36.jpg)
Interacting with Button
36
![Page 37: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/37.jpg)
Interacting with Buttons
37
![Page 38: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/38.jpg)
38
![Page 39: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/39.jpg)
Screen Navigation
39
![Page 40: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/40.jpg)
40
![Page 41: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/41.jpg)
41
![Page 42: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/42.jpg)
42
![Page 43: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/43.jpg)
43
![Page 44: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/44.jpg)
44
![Page 45: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/45.jpg)
45
![Page 46: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/46.jpg)
startActivityForResult()
46
![Page 47: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/47.jpg)
47
![Page 48: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/48.jpg)
48
![Page 49: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/49.jpg)
49
![Page 50: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/50.jpg)
50
![Page 51: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/51.jpg)
51
![Page 52: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/52.jpg)
Intents
52
![Page 53: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/53.jpg)
Understanding Intent
Need• Class Name
Need • ACTION• CATEGORY• DATA
![Page 54: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/54.jpg)
Program Launcher<?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 55: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/55.jpg)
Conflicts with implicit IntentsSo 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 system that application as the default application hence forth
![Page 56: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/56.jpg)
Intent API ReferenceIntent to launch an Activity
• Context.startActivity(intent)
• Context.startActivityForResult(intent)
Intent to launch an Service
• Context.startService(intent)
Intent to send a broadcast
• Context.sendBroadCast(intent)
![Page 57: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/57.jpg)
Activity
57
![Page 58: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/58.jpg)
Activity Life Cycle
![Page 59: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/59.jpg)
ForegroundLifeCycleVisible LifeCycleComplete
LifeCycle
Activity Life Cycle (made easy)
onCreate
onDestroy
onStart
onStop
onResume
onPause
![Page 60: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/60.jpg)
What to do in what method?
onCreate
onDestroy
onStart
onStop
onResume
onPause
![Page 61: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/61.jpg)
Services
61
![Page 62: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/62.jpg)
Calling Service
Activity
Service
void onStartCommand(Intent intent,…){}
startService(intent)
Fire & Forget
![Page 63: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/63.jpg)
Calling Service
Activity
Service
1. bindService(intent)2. …..3. service.foo()4. int result=service.bar()
void foo(){}int bar(){}
RPC Style
![Page 64: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/64.jpg)
64
![Page 65: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/65.jpg)
Broadcast Receivers
65
![Page 66: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/66.jpg)
Broadcast ReceiversApp 1
Android OS
App 2
Your App
Custom Event 1
Custom Event 2
Battery Low
RoamingBoot
Network Change
Interested in any of these Events.
![Page 67: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/67.jpg)
Broadcast Receivers
• No Life Cycle Methods• Only Call back method• 10 second limit before ANR• Need not register with Android Manifest• Can be registered at Runtime
![Page 68: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/68.jpg)
Use case Email Application
68
![Page 69: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/69.jpg)
Mail Application – Use Case
![Page 70: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/70.jpg)
Building Blocks of Android
Activity Service BroadcastReceiver
Content Provider/
SQL ite Database
Mail Sync Data Store(Email List)
Phone Boots
Communication is using Intents
![Page 71: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/71.jpg)
Activity
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..Notifi. M..
Phone Boots
![Page 72: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/72.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
![Page 73: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/73.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
Broadcast R
![Page 74: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/74.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
Broadcast R
![Page 75: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/75.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
starts
![Page 76: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/76.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
Completes
![Page 77: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/77.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
Stores
![Page 78: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/78.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
Stores
Mail Notification
![Page 79: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/79.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
Mail Notification
![Page 80: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/80.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
Mail Notification
Data Store(Email List)
Database
![Page 81: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/81.jpg)
Mail Sync
ServicePhone Boots
Broadcast R
Data Store(Email List)
Database
Events..
Alarm M..
Phone Boots Mail
Sync (5 mins)
Activity
Notifi. M..
Mail Notification
![Page 82: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/82.jpg)
Twitter App
• All these Building blocks are covered in more detail on 3rd November at 3:40 p.m in “Building Twitter App for Android”
82
![Page 83: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/83.jpg)
Q & A
83
![Page 84: Getting Started with Android Development](https://reader036.vdocuments.us/reader036/viewer/2022081604/56815e7e550346895dcd0998/html5/thumbnails/84.jpg)
More about Me• Twitter - http://twitter.com/#!/rohitghatol • TechGig -
http://www.techgig.com/rohitghatol • LinkedIn -
http://www.linkedin.com/in/rohitghatol• Presentations -
www.slideshare.net/rohitsghatol/ • YouTube Tutorials -
http://www.youtube.com/user/rohitssghatol