1
Android Basics
Rohit Ghatol
QuickOffice
& Synerzip
2
About Me
Name: Rohit Ghatol
Occupation:
1. Architect @QuickOffice
2. Project Mgr @Synerzip
3. Certified Scrum Master
Thi...
3
Topics
Introduction to Android
Android OS Capabilities
Building Blocks of Android
Understanding HelloWorld
Use Case...
4
Introduction to Android
• Software stack for mobile devices that
includes
• an operating system
• middleware
• key appli...
5
Introduction to Android
6
Introduction to Android
• About Android Applications
• Written in Java
• Compiled to .dex
• Run in Dalvik VM
• Packaged ...
7
Introduction to Android
• About Dalvik VM
• Cut from Apache Harmony Project
• Device can run multiple VMs efficiently
• ...
8
More about Applications
Dalvik VM
Linux Process
Linux Kernel
Process Process Process
Dalvik
VM
Dalvik
VM
Dalvik
VM
Uid 1...
9
Android Versions
OS
Version
Nickname API Level Date Comments
1.1 __ 2 February 2009
1.5 Cupcake 3 30 April 2009 Based on...
10
Android OS Capabilities
Features
• Phone and OS features
• 3G, GPS, Accelerometer, SQLite, Camera,
Telephony, Webkit, e...
11
Android Phone Demo
Before anything you must see what an
Android Phone looks like!
1.Desktop
2.Notification Bar
3.Contac...
12
Reuse of Data
Default Contact
Manager
New Contact
Manager
Replaces
What happens to data
feed into the default
Contact M...
13
Reuse of Data
Default Contact
Manager
New Contact
Manager
Replaces
Content
Provider
But Uses
14
Reuse of Functionality
Sudoko Game New Requirement
Share with Friends using
1.SMS
2.Email
Time to learn SMS API
and Ema...
15
Reuse of Functionality
Sudoko Game
SMS
Mail
SMS
Mail
Intention: Want
to send Email
Here are two
applications who
can do...
16
Reuse of Functionality
Sudoko Game
SMS
Mail
SMS
Mail
Intention: Want
to send Email
17
Building Blocks of Android
Activity
(Screen)
Service
(Background)
Broadcast
Receiver
(respond to
events)
Content
Provid...
18
Environment Setup
19
Environment Setup
20
Environment Setup
Text
21
Text
Environment Setup
22
Simple HelloWorld
Text
23
Simple HelloWorld
Text
24
Simple HelloWorld
Text
25
Simple HelloWorld
Text
26
Simple HelloWorld
Text
27
Simple HelloWorld
Text
28
Simple HelloWorld
Text
29
Simple HelloWorld
Text
30
Simple HelloWorld
Text
31
Simple HelloWorld
Text
32
Simple HelloWorld
Text
33
Simple HelloWorld
Text
34
Simple HelloWorld
Text
35
Simple HelloWorld
Text
36
Simple HelloWorld
Text
37
Simple HelloWorld
Text
38
Simple HelloWorld
Text
39
Simple HelloWorld
Text
40
Building Application .
You need a Screen (Activity)
Views could be
• Buttons
• Text Views
• etc ….
Layouts could be
• L...
41
Building Block - Activity
Activity Life Cycle
42
Foreground
LifeCycle
Visible
LifeCycle
Complete
LifeCycle
Building Block - Activity
Activity Life Cycle made easier
onC...
43
Building Block - Activity
What to do in each life cycle methods?
onCreate
onDestroy
onStart
onStop
onResume
onPause
44
Building Block - Service
Service
LifeCycle
45
Building Block – Broadcast Receiver
1. Broadcast Receiver is more of a Call
back
2. Android will call your Broadcast
re...
46
Building Block – Content Provider
1. Content Provider are more of RestFul
like exposed Database
2. They are accessed us...
47
Building Block – Intents
Need
• Class Name
Need
• ACTION
• CATEGORY
• DATA
48
Building Block – Intents
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk...
49
Building Application .
So what happens two activities have the exact same intent filter
and an intent is fired.
Simple ...
50
Building Application .
Intent to launch an Activity
• Context.startActivity(intent)
• ContextstartActivityForResult(int...
51
Building Block – Permissions
<manifest xmlns:android="http://schemas.android.com/apk/res/android
package="com.android.a...
52
Understanding Android UI
• Lets Draw the Screen using Linear Layouts
Current Playlist
Player
53
Understanding Android UI
• Lets Draw the Screen using Linear Layouts
Current Music Info
Progress Bar
Buttons
Music file...
54
Understanding Android UI
• Lets Draw the Screen using Linear Layouts
Current Music Info
Progress Bar
Music file 1
Music...
55
Layout XML
………………………….
………………………….
56
Understanding Android UI
• Lets Draw the Screen using Relative Layouts
Beautiful World
Take That
Title is aligned to th...
57
Layout XML
58
Understanding Android UI
Use Layouts
Layouts can be defined in different XML files
Code can refer to these layout xml f...
59
Gmail Application – Use Case
60
Building Blocks of Android
ActivityActivity ServiceService Broadcast
Receiver
Broadcast
Receiver
Content
Provider/
SQL ...
61
Activity
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Al...
62
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
63
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
64
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
65
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
66
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
67
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
68
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
69
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
70
Gmail Sync
ServicePhone Boots
Broadcast R
Data Store
(Email List)
Data Store
(Email List)
Database
Events..
Alarm M..
P...
71
References & Further Reading
1. What is Android?
2. Android Fundamentals
3. Notepad Guided Tutorial
4. Common Tasks?
5....
72
Youtube Videos - Android
http://www.youtube.com/user/GoogleDevelopers#g/c/316B437F0CB82A68
73
Reach Me
1. Linked In
2. Email – rohitsghatol@gmail.com
Upcoming SlideShare
Loading in...5
×

Indic thread 2010-android-basics

237

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
237
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Indic thread 2010-android-basics

  1. 1. 1 Android Basics Rohit Ghatol QuickOffice & Synerzip
  2. 2. 2 About Me Name: Rohit Ghatol Occupation: 1. Architect @QuickOffice 2. Project Mgr @Synerzip 3. Certified Scrum Master Thinks I like to do: 1. Talk at Technical Platforms 2. Agile Evangelism 3. Motivational Speaker and Trainer LinkedIn ProfileLinkedIn Profile
  3. 3. 3 Topics Introduction to Android Android OS Capabilities Building Blocks of Android Understanding HelloWorld Use Case – Building Blocks in Gmail Client Understanding Android UI References & Further Reading
  4. 4. 4 Introduction to Android • Software stack for mobile devices that includes • an operating system • middleware • key applications • SDK to develop application
  5. 5. 5 Introduction to Android
  6. 6. 6 Introduction to Android • About Android Applications • Written in Java • Compiled to .dex • Run in Dalvik VM • Packaged and Shipped as APK
  7. 7. 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
  8. 8. 8 More about Applications Dalvik VM Linux Process Linux Kernel Process Process Process Dalvik VM Dalvik VM Dalvik VM Uid 1Uid 1 Uid 2Uid 2 Uid 3Uid 3 data data com.xyz.email com.abc.skype com.koko.sukudo shared_prefs files databases . . . . . . . . . . . . UID 1 UID 2 UID 3
  9. 9. 9 Android Versions OS 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
  10. 10. 10 Android OS Capabilities Features • Phone and OS features • 3G, GPS, Accelerometer, SQLite, Camera, Telephony, Webkit, etc • Reuse of Data • Reuse of Functionality
  11. 11. 11 Android Phone Demo Before anything you must see what an Android Phone looks like! 1.Desktop 2.Notification Bar 3.Contact Manager 4.Gmail Application
  12. 12. 12 Reuse of Data Default Contact Manager New Contact Manager Replaces What happens to data feed into the default Contact Manager?
  13. 13. 13 Reuse of Data Default Contact Manager New Contact Manager Replaces Content Provider But Uses
  14. 14. 14 Reuse of Functionality Sudoko Game New Requirement Share with Friends using 1.SMS 2.Email Time to learn SMS API and Email API and code them into my application! More code! Hee hee 
  15. 15. 15 Reuse of Functionality Sudoko Game SMS Mail SMS Mail Intention: Want to send Email Here are two applications who can do it for you.
  16. 16. 16 Reuse of Functionality Sudoko Game SMS Mail SMS Mail Intention: Want to send Email
  17. 17. 17 Building Blocks of Android Activity (Screen) Service (Background) Broadcast Receiver (respond to events) Content Provider (Database/ Directory) Notification Manager ...... Alarm Manager Read more - http://developer.android.com/guide/topics/fundamentals.html
  18. 18. 18 Environment Setup
  19. 19. 19 Environment Setup
  20. 20. 20 Environment Setup Text
  21. 21. 21 Text Environment Setup
  22. 22. 22 Simple HelloWorld Text
  23. 23. 23 Simple HelloWorld Text
  24. 24. 24 Simple HelloWorld Text
  25. 25. 25 Simple HelloWorld Text
  26. 26. 26 Simple HelloWorld Text
  27. 27. 27 Simple HelloWorld Text
  28. 28. 28 Simple HelloWorld Text
  29. 29. 29 Simple HelloWorld Text
  30. 30. 30 Simple HelloWorld Text
  31. 31. 31 Simple HelloWorld Text
  32. 32. 32 Simple HelloWorld Text
  33. 33. 33 Simple HelloWorld Text
  34. 34. 34 Simple HelloWorld Text
  35. 35. 35 Simple HelloWorld Text
  36. 36. 36 Simple HelloWorld Text
  37. 37. 37 Simple HelloWorld Text
  38. 38. 38 Simple HelloWorld Text
  39. 39. 39 Simple HelloWorld Text
  40. 40. 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 …..
  41. 41. 41 Building Block - Activity Activity Life Cycle
  42. 42. 42 Foreground LifeCycle Visible LifeCycle Complete LifeCycle Building Block - Activity Activity Life Cycle made easier onCreate onDestroy onStart onStop onResume onPause
  43. 43. 43 Building Block - Activity What to do in each life cycle methods? onCreate onDestroy onStart onStop onResume onPause
  44. 44. 44 Building Block - Service Service LifeCycle
  45. 45. 45 Building Block – Broadcast Receiver 1. Broadcast Receiver is more of a Call back 2. Android will call your Broadcast receiver depending on the intent filter
  46. 46. 46 Building Block – Content Provider 1. Content Provider are more of RestFul like exposed Database 2. They are accessed using Content Resolver 3. They can allow full CRUD Operations on them (Any application can add/delete/edit contacts in Phone’s Contact Manager)
  47. 47. 47 Building Block – Intents Need • Class Name Need • ACTION • CATEGORY • DATA
  48. 48. 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
  49. 49. 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
  50. 50. 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
  51. 51. 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>
  52. 52. 52 Understanding Android UI • Lets Draw the Screen using Linear Layouts Current Playlist Player
  53. 53. 53 Understanding Android UI • Lets Draw the Screen using Linear Layouts Current Music Info Progress Bar Buttons Music file 1 Music file 2 Music file 3 Music file 4
  54. 54. 54 Understanding Android UI • Lets Draw the Screen using Linear Layouts Current Music Info Progress Bar Music file 1 Music file 2 Music file 3 Music file 4 Prev NextPlay
  55. 55. 55 Layout XML …………………………. ………………………….
  56. 56. 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
  57. 57. 57 Layout XML
  58. 58. 58 Understanding Android UI Use Layouts Layouts can be defined in different XML files Code can refer to these layout xml files
  59. 59. 59 Gmail Application – Use Case
  60. 60. 60 Building Blocks of Android ActivityActivity ServiceService Broadcast Receiver Broadcast Receiver Content Provider/ SQL ite Database Content Provider/ SQL ite Database Gmail Sync Data Store (Email List) Data Store (Email List) Phone Boots Communication is using IntentsCommunication is using Intents
  61. 61. 61 Activity Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Notifi. M.. Phone Boots
  62. 62. 62 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M..
  63. 63. 63 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M..
  64. 64. 64 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M.. starts
  65. 65. 65 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M.. Completes
  66. 66. 66 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M.. Stores
  67. 67. 67 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M.. Stores Gmail Notification
  68. 68. 68 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M.. Gmail Notification
  69. 69. 69 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M.. Gmail Notification
  70. 70. 70 Gmail Sync ServicePhone Boots Broadcast R Data Store (Email List) Data Store (Email List) Database Events.. Alarm M.. Phone Boots Gmail Sync (5 mins) Activity Notifi. M.. Gmail Notification
  71. 71. 71 References & Further Reading 1. What is Android? 2. Android Fundamentals 3. Notepad Guided Tutorial 4. Common Tasks? 5. Articles and Docs 6. Best Practices - Performance
  72. 72. 72 Youtube Videos - Android http://www.youtube.com/user/GoogleDevelopers#g/c/316B437F0CB82A68
  73. 73. 73 Reach Me 1. Linked In 2. Email – rohitsghatol@gmail.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×