Getting Started With Android

40
07/05/22 Google Android a Start Mobile without Linux is like Forest without birds SOMS Lecture Series 02

Transcript of Getting Started With Android

Page 1: Getting Started With Android

05/03/23 Google Android a Start

Mobile without Linux is like Forest without birds

SOMS Lecture Series 02

Page 2: Getting Started With Android

05/03/23 Google Android a Start

Getting started withGoogle Android

M Qasim AliPresident, SOMS

June 25th 2009

Page 3: Getting Started With Android

05/03/23 Google Android a Start

Agenda● Android platform ● Development tools ● Android programming

Page 4: Getting Started With Android

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”

Page 5: Getting Started With Android

05/03/23 Google Android a Start

Android applications● are written in the Java language● run on the Dalvik virtual machine

Page 6: Getting Started With Android

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

Page 7: Getting Started With Android

05/03/23 Google Android a Start

Getting started

Page 8: Getting Started With Android

05/03/23 Google Android a Start

Development tools● Android SDK● Eclipse plugin

Page 9: Getting Started With Android

05/03/23 Google Android a Start

Android SDK● Android emulator● command line tools● documentation● example applications

Page 10: Getting Started With Android

05/03/23 Google Android a Start

Android emulator

Page 11: Getting Started With Android

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

Page 12: Getting Started With Android

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

Page 13: Getting Started With Android

05/03/23 Google Android a Start

Eclipse plugin

Page 14: Getting Started With Android

05/03/23 Google Android a Start

Android applications● application package file: myapp.apk● an application is composed of one or more

activities

Page 15: Getting Started With Android

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

Page 16: Getting Started With Android

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);}}

Page 17: Getting Started With Android

05/03/23 Google Android a Start

Page 18: Getting Started With Android

05/03/23 Google Android a Start

Application Building blocks

● AndroidManifest.xml● Activities● Views● Layouts

● Intents & IntentReceivers

● Services● Notifications● ContentProviders

Page 19: Getting Started With Android

05/03/23 Google Android a Start

App main User Interface

Will create app layout according to the xml description: main.xml

Page 20: Getting Started With 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

Page 21: Getting Started With Android

05/03/23 Google Android a Start

Manifest file

AndroidManifest.xml

Apps behavior in Android system

Page 22: Getting Started With Android

05/03/23 Google Android a Start

Implementing yourapplication UI

● Java code● XML

Page 23: Getting Started With Android

05/03/23 Google Android a Start

Android UI: XML

App main User Interface

Page 24: Getting Started With Android

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

Page 25: Getting Started With Android

05/03/23 Google Android a Start

< TextView >

< LinearLayout >

Page 26: Getting Started With Android

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”

Page 27: Getting Started With Android

05/03/23 Google Android a Start

android.content.Intent● VIEW_ACTION● EDIT_ACTION● PICK_ACTION● WEB_SEARCH_ACTION● SYNC_ACTION● ...

Page 28: Getting Started With Android

05/03/23 Google Android a Start

Application Context● android.app.ApplicationContext

– startActivity(Intent)– getSystemService– createDatabase– openDatabase– deleteDatabase– ...

Page 29: Getting Started With Android

05/03/23 Google Android a Start

Additional topics● Threading● Security model● Internationalization● Power management

● AIDL - Android IDL● Data synchronization● API for WiFi

Page 30: Getting Started With Android

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

Page 31: Getting Started With Android

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.

Page 32: Getting Started With Android

05/03/23 Google Android a Start

Application: Hello Android!

Page 33: Getting Started With 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

Page 34: Getting Started With Android

05/03/23 Google Android a Start

App main User Interface

Resource delimitations

Apps behavior in Android system

Page 35: Getting Started With Android

05/03/23 Google Android a Start

Apps behavior in Android system

App’s source code

Page 36: Getting Started With Android

05/03/23 Google Android a Start

Page 37: Getting Started With Android

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

Page 38: Getting Started With Android

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()

Page 39: Getting Started With Android

05/03/23 Google Android a Start

App main User Interface

Will create app layout according to the xml description: main.xml

Page 40: Getting Started With Android

05/03/23 Google Android a Start

< TextView >

< LinearLayout >