Getting Started With Android
-
Upload
qasim-khawaja -
Category
Technology
-
view
5.682 -
download
2
Transcript of Getting Started With Android
05/03/23 Google Android a Start
Mobile without Linux is like Forest without birds
SOMS Lecture Series 02
05/03/23 Google Android a Start
Getting started withGoogle Android
M Qasim AliPresident, SOMS
June 25th 2009
05/03/23 Google Android a Start
•
Agenda● Android platform ● Development tools ● Android programming
05/03/23 Google Android a Start
What is Android?● “Android is a software stack for mobile
devices that includes an operating system, middleware and key applications”
05/03/23 Google Android a Start
Android applications● are written in the Java language● run on the Dalvik virtual machine
05/03/23 Google Android a Start
Dalvik VM● not a Java VM● design constraints: slow CPU, little RAM● will run on OS without swap space● http://sites.google.com/site/io/dalvik-vm-
internals
05/03/23 Google Android a Start
•
Getting started
05/03/23 Google Android a Start
Development tools● Android SDK● Eclipse plugin
05/03/23 Google Android a Start
Android SDK● Android emulator● command line tools● documentation● example applications
05/03/23 Google Android a Start
•
Android emulator
05/03/23 Google Android a Start
Command line tools● aapt - Android asset packaging tool● adb - Android debug bridge● aidl - Android IDL compiler● emulator - Android emulator
05/03/23 Google Android a Start
Emulator limitations● No support for placing or receiving actual phone● calls● No support for camera/video capture (input)● No support for audio input● No support for determining connected state● No support for determining battery charge level● No support for Bluetooth
05/03/23 Google Android a Start
Eclipse plugin
05/03/23 Google Android a Start
Android applications● application package file: myapp.apk● an application is composed of one or more
activities
05/03/23 Google Android a Start
Activity● an activity is usually a single screen in
your application● however, activities can also be faceless● one activity is designated as the entry
point for your application
05/03/23 Google Android a Start
android.app.Activityimport android.app.Activity;public class MyActivity extends Activity{ public void onCreate(Bundle savedValues){ super.onCreate(savedValues); setContentView(R.layout.main);}}
05/03/23 Google Android a Start
05/03/23 Google Android a Start
Application Building blocks
● AndroidManifest.xml● Activities● Views● Layouts
● Intents & IntentReceivers
● Services● Notifications● ContentProviders
05/03/23 Google Android a Start
App main User Interface
Will create app layout according to the xml description: main.xml
05/03/23 Google Android a Start
So
urce
cod
e La
yout
Resource file: aapt toolApp’s source codeApp’s packageAndroid Project
Android built in packages – Wifi, GSM, other sensors
Apps behavior in Android system
App main User InterfaceResource delimitations
05/03/23 Google Android a Start
Manifest file
AndroidManifest.xml
Apps behavior in Android system
05/03/23 Google Android a Start
Implementing yourapplication UI
● Java code● XML
05/03/23 Google Android a Start
Android UI: XML
App main User Interface
05/03/23 Google Android a Start
Android UI: Views● an object that knows how to draw itself on
the screen● examples:
– android.widget.ListView– android.widget.DatePicker– android.widget.Button– android.widget.ImageView
05/03/23 Google Android a Start
< TextView >
< LinearLayout >
05/03/23 Google Android a Start
Intents● “an Intent is a simple message object that
represents an ‘intention’ to do something”● “an intent is an abstract description of an
operation to be performed”
05/03/23 Google Android a Start
android.content.Intent● VIEW_ACTION● EDIT_ACTION● PICK_ACTION● WEB_SEARCH_ACTION● SYNC_ACTION● ...
05/03/23 Google Android a Start
Application Context● android.app.ApplicationContext
– startActivity(Intent)– getSystemService– createDatabase– openDatabase– deleteDatabase– ...
05/03/23 Google Android a Start
Additional topics● Threading● Security model● Internationalization● Power management
● AIDL - Android IDL● Data synchronization● API for WiFi
05/03/23 Google Android a Start
Additional Resources ● http://code.google.com/android/● http://android-developers.blogspot.com● http://code.google.com/p/apps-for-android/● http://sites.google.com/site/io/● http://www.openhandsetalliance.com/● http://git.android.com
05/03/23 Google Android a Start
Application vs. Activity● An application can be
composed of multiple Activities, but one application must have at least one Activity.
● Each “window” or screen of your application is a separate Activity.
05/03/23 Google Android a Start
•
Application: Hello Android!
05/03/23 Google Android a Start
So
urce
cod
e La
yout
Resource file: aapt toolApp’s source codeApp’s packageAndroid Project
Android built in packages – Wifi, GSM, other sensors
Apps behavior in Android system
App main User InterfaceResource delimitations
05/03/23 Google Android a Start
App main User Interface
Resource delimitations
Apps behavior in Android system
05/03/23 Google Android a Start
Apps behavior in Android system
App’s source code
05/03/23 Google Android a Start
05/03/23 Google Android a Start
public non-public
We are writing a function that is present in parent class Activity as PROTECTED member
inherited
derived
05/03/23 Google Android a Start
publicnon-public: protected
inherited
derived Activity
HelloAndroid
Public: OnCreate()
inherited
derived
keyword: super refers to the data member inherited from the base class
Protected: OnCreate()
super.OnCreate()
05/03/23 Google Android a Start
App main User Interface
Will create app layout according to the xml description: main.xml
05/03/23 Google Android a Start
< TextView >
< LinearLayout >