Getting Started with Android Development Rohit Ghatol
About Me Rohit Ghatol 2.Project 3.Certified Scrum Master 4.Author “Beginning PhoneGap 5.Founder TechNext Pune (Pune Developer Community)TechNext LinkedIn Profile LinkedIn Profile
Topics Understanding Android Android Building Blocks Putting Building Blocks Together Latest things in Android World Reference Material 3
Understanding Android 4
What is Android? Software stack for mobile devices that includes an operating system middleware key applications SDK to develop application 5
Android Architecture 6
Android OS Names 7
8 OS Version NicknameAPI LevelDate 1.1__29 th February Cupcake330 April Donut45 September Eclair726 October Froyo820 May Gingerbread96 th December Honeycomb1122 nd February XIcecream Sandwich 1419 th October
Key OS Capabilities 9
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
Android OS Capabilities Notable Features of Android – All Applications are equal – Reuse of Data – Reuse of Functionality
All Applications are Equal Replace Home Application Replace Contacts, Dialer Applications Replace SMS, Applications Replace Settings Application OEM Customizations (e.g HTC Sense) 12
Reuse of Data Default Contact Manager Replaces What happens to data feed into the default Contact Manager? New Contact Manager
Reuse of Data Default Contact Manager Replaces New Contact Manager Content Provider But Uses “Replaces” means by default the new app is launched, but old app still exists
Reuse of Functionality New Requirement Share with Friends using 1.SMS 2. Time to learn SMS API and API and code them into my application! More code! Hee hee My Coupons
Reuse of Functionality SMS Mail Intention: Want to send Here are two applications who can do it for you? My Coupons
Reuse of Functionality SMS Mail My Coupons
Reuse of Functionality SMS Mail My Coupons
Android Environment Setup stalling.html 19
20 Android SDK Eclipse ADT Android ….. ………………. Android 3.2 Android 4.x Android 2.2 Google API 2.2 SDK Manager AVD Manager Manages Emulator
Android Application Dex File Android Manifest Resources MyApp.apk Signed by Self Signed Private Key
Identity of Android Application 22 Identity PartExample Package Namecom.sparklytix.android.app.twitter versionCode1 (numeric value 2,3,4,..101,102) Private Key
Android Build Cycle 23.java.apk.dex.class javacdx apt AndroidManifest.xml resources AndroidManifest.xml resources
How Applications behave? 24
25 Dalvik VM Linux Process Linux Kernel Process Dalvik VM Dalvik VM Dalvik VM Uid 1 Uid 2 Uid 3 data com.xyz. com.abc.skype com.koko.sukudo shared_prefs files databases... UID 1 UID 2 UID 3
Android Building Blocks 26
Read more - Activity Service Broadcast Receiver Alarm Manager Noti- fication Manager Content Provider Intents Content Resolver Building Blocks Other Components ……
First Android Application 28
29
30
31
32
33
34
Interacting with Buttons 35
Interacting with Button 36
Interacting with Buttons 37
38
Screen Navigation 39
40
41
42
43
44
45
startActivityForResult() 46
47
48
49
50
51
Intents 52
Understanding Intent IntentsExplicitImplicit Need Class Name Need ACTION CATEGORY DATA
Program Launcher <manifest xmlns:android=" package="com.sample“ android:versionCode="1“ android:versionName="1.0"> <activity android:name=".HelloWorld" Program launcher shows all the activities which have MAIN Action and LAUNCHER category
Conflicts with implicit Intents 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 system that application as the default application hence forth
Intent API Reference Intent 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)
Activity 57
Activity Life Cycle
Foreground LifeCycle Visible LifeCycle Complete LifeCycle Activity Life Cycle (made easy) onCreate onDestroy onStart onStop onResume onPause
What to do in what method? onCreate onDestroy onStart onStop onResume onPause
Services 61
Calling Service Activity Service void onStartCommand (Intent intent,…){ } startService(intent) Fire & Forget
Calling Service Activity Service 1.bindService(intent) 2.….. 3.service.foo() 4.int result=service.bar() void foo(){ } int bar(){ } RPC Style
64
Broadcast Receivers 65
Broadcast Receivers App 1 Android OS App 2 Your App Custom Event 1 Custom Event 2 Battery Low Roaming Boot Network Change Interested in any of these Events.
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
Use case Application 68
Mail Application – Use Case
Building Blocks of Android ActivityService Broadcast Receiver Content Provider/ SQL ite Database Mail Sync Data Store ( List) Phone Boots Communication is using Intents
Activity Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events.. Alarm M.. Notifi. M.. Phone Boots
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M..
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. Broadcast R
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. Broadcast R
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. starts
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. Completes
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. Stores
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. Stores Mail Notification
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. Mail Notification
Mail Sync Service Phone Boots Broadcast R Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. Mail Notification Data Store ( List) Database
Mail Sync Service Phone Boots Broadcast R Data Store ( List) Database Events..Alarm M.. Phone Boots Mail Sync (5 mins) Activity Notifi. M.. Mail Notification
Twitter App All these Building blocks are covered in more detail on 3 rd November at 3:40 p.m in “Building Twitter App for Android”Building Twitter App for Android 82
Q & A 83
More about Me Twitter - TechGig - LinkedIn Presentations YouTube Tutorials -