Android Introduction Platform Overview 1 What is Android

  • Slides: 30
Download presentation
Android Introduction Platform Overview 1

Android Introduction Platform Overview 1

What is Android? p Android is a software stack for mobile devices that includes

What is Android? p Android is a software stack for mobile devices that includes an operating system, middleware and key applications. 2

OHA (Open Handset Alliance) p. A business alliance consisting of 47 companies to develop

OHA (Open Handset Alliance) p. A business alliance consisting of 47 companies to develop open standards for mobile devices 3

Phones HTC G 1, Droid, Tattoo Suno S 880 Motorola Droid (X) Samsung Galaxy

Phones HTC G 1, Droid, Tattoo Suno S 880 Motorola Droid (X) Samsung Galaxy Sony Ericsson 4

Tablets Velocity Micro Cruz Dawa D 7 Gome Fly. Touch Toshiba Android Smart. Book

Tablets Velocity Micro Cruz Dawa D 7 Gome Fly. Touch Toshiba Android Smart. Book Acer be. Touch Cisco Android Tablet 5

Architecture 6

Architecture 6

Android S/W Stack - Application p Android provides a set of core applications: ü

Android S/W Stack - Application p Android provides a set of core applications: ü ü ü ü p Email Client SMS Program Calendar Maps Browser Contacts Etc All applications are written using the Java language. 7

Android S/W Stack – App Framework p Enabling and simplifying the reuse of components

Android S/W Stack – App Framework p Enabling and simplifying the reuse of components ü ü Developers have full access to the same framework APIs used by the core applications. Users are allowed to replace components. 8

Android S/W Stack – App Framework (Cont) p Features Feature Role View System Used

Android S/W Stack – App Framework (Cont) p Features Feature Role View System Used to build an application, including lists, grids, text boxes, buttons, and embedded web browser Content Provider Enabling applications to access data from other applications or to share their own data Resource Manager Providing access to non-code resources (localized strings, graphics, and layout files) Notification Manager Enabling all applications to display customer alerts in the status bar Activity Manager Managing the lifecycle of applications and providing a common navigation back-stack 9

Android S/W Stack - Libraries p Including a set of C/C++ libraries used by

Android S/W Stack - Libraries p Including a set of C/C++ libraries used by components of the Android system p Exposed to developers through the Android application framework 10

Android S/W Stack – Runtime p Core Libraries ü ü Providing most of the

Android S/W Stack – Runtime p Core Libraries ü ü Providing most of the functionality available in the core libraries of the Java language APIs Ø Ø Ø Data Structures Utilities File Access Network Access Graphics 11

Android S/W Stack – Runtime (Cont) p Dalvik Virtual Machine ü Providing environment on

Android S/W Stack – Runtime (Cont) p Dalvik Virtual Machine ü Providing environment on which every Android application runs Ø Ø ü Each Android application runs in its own process, with its own instance of the Dalvik VM. Dalvik has been written such that a device can run multiple VMs efficiently. Register-based virtual machine 12

Android S/W Stack – Runtime p Dalvik Virtual Machine (Cont) ü Executing the Dalvik

Android S/W Stack – Runtime p Dalvik Virtual Machine (Cont) ü Executing the Dalvik Executable (. dex) format Ø Ø ü . dex format is optimized for minimal memory footprint. Compilation Relying on the Linux Kernel for: Ø Ø Threading Low-level memory management 13

Android S/W Stack – Linux Kernel l l Relying on Linux Kernel 2. 6

Android S/W Stack – Linux Kernel l l Relying on Linux Kernel 2. 6 for core system services ü Memory and Process Management ü Network Stack ü Driver Model ü Security Providing an abstraction layer between the H/W and the rest of the S/W stack 14

Android SDK Once installed open the SDK Manager p Install the desired packages p

Android SDK Once installed open the SDK Manager p Install the desired packages p Create an Android Virtual Device (AVD) p

SDK Manager

SDK Manager

AVD

AVD

Project Components src – your source code p gen – auto-generated code (usually just

Project Components src – your source code p gen – auto-generated code (usually just R. java) p Included libraries p Resources p n n n p Drawables (like. png images) Layouts Values (like strings) Manifest file

XML p Used to define some of the resources n n Layouts (UI) Strings

XML p Used to define some of the resources n n Layouts (UI) Strings Manifest file p Shouldn’t usually have to edit it directly, Eclipse can do that for you p Preferred way of creating UIs p n n Separates the description of the layout from any actual code that controls it Can easily take a UI from one platform to another

R Class Auto-generated: you shouldn’t edit it p Contains IDs of the project resources

R Class Auto-generated: you shouldn’t edit it p Contains IDs of the project resources p Enforces good software engineering p Use find. View. By. Id and Resources object to get access to the resources p n n Ex. Button b = (Button)find. View. By. Id(R. id. button 1) Ex. get. Resources(). get. String(R. string. hello));

Layouts p Eclipse has a great UI creator n Generates the XML for you

Layouts p Eclipse has a great UI creator n Generates the XML for you Composed of View objects p Can be specified for portrait and landscape mode p n Use same file name, so can make completely different UIs for the orientations without modifying any code

Strings p In res/values n strings. xml Application wide available strings p Promotes good

Strings p In res/values n strings. xml Application wide available strings p Promotes good software engineering p UI components made in the UI editor should have text defined in strings. xml p p Strings are just one kind of ‘Value’ there are many others

Manifest File p p Contains characteristics about your application When have more than one

Manifest File p p Contains characteristics about your application When have more than one Activity in app, NEED to specify it in manifest file n n n p p Go to graphical view of the manifest file Add an Activity in the bottom right Browse for the name of the activity Need to specify Services and other components too Also important to define permissions and external libraries, like Google Maps API

Android Programming Components p Activity n p http: //developer. android. com/guide/topics/fundamentals/activi ties. html Service

Android Programming Components p Activity n p http: //developer. android. com/guide/topics/fundamentals/activi ties. html Service n http: //developer. android. com/guide/topics/fundamentals/servi ces. html Content Providers p Broadcast Receivers p Android in a nutshell: p n http: //developer. android. com/guide/topics/fundamental s. html

Activities (1) The basis of android applications p A single Activity defines a single

Activities (1) The basis of android applications p A single Activity defines a single viewable screen p n the actions, not the layout Can have multiple per application p Each is a separate entity p They have a structured life cycle p n Different events in their life happen either via the user touching buttons or programmatically

Activities (2)

Activities (2)

Services (1) p Run in the background n Can continue even if Activity that

Services (1) p Run in the background n Can continue even if Activity that started it dies n Should be used if something needs to be done while the user is not interacting with application p p p Otherwise, a thread is probably more applicable Should create a new thread in the service to do work in, since the service runs in the main thread Can be bound to an application n In which case will terminate when all applications bound to it unbind n Allows multiple applications to communicate with it via a common interface Needs to be declared in manifest file Like Activities, has a structured life cycle

Services (2)

Services (2)

Android Debug Bridge p Used for a wide variety of developer tasks n n

Android Debug Bridge p Used for a wide variety of developer tasks n n n p In the ‘platform-tools’ directory of the main android sdk directory n p Read from the log file Show what android devices are available Install android applications (. apk files) Recommend putting this directory and the ‘tools’ directory on the system path adb. exe

Acknowledgements p p Android Developer’s Website n Activity and Service life-cycle flow charts n

Acknowledgements p p Android Developer’s Website n Activity and Service life-cycle flow charts n Tons of other Android info Google Maps API external library n p http: //code. google. com/android/add-ons/google-apis/maps-overview. html Numerous Forums & other developer sites, including: n n n n http: //www. javacodegeeks. com/2011/02/android-google-maps-tutorial. html http: //efreedom. com/Question/1 -6070968/Google-Maps-Api-Directions http: //www. mail-archive. com/android-developers@googlegroups. com/msg 28487. html http: //android. bigresource. com/ threads http: //groups. google. com/group/android-developers threads Many http: //stackoverflow. com threads http: //www. anddev. org/google_driving_directions_-_mapview_overlayedt 826. html