Android: An Overview By-: Akash Singh & Dalveer Kaur Branch-: CS-1

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 24

ANDROID

 An Overview
 By-: Akash Singh &
Dalveer kaur
 Branch-: CS-1
Outline

 Introduction
 Application Components and Lifecycle
 User Interfaces
 Binding applications and their components
 Data Storage
 Background Services
 Location-Based Services
 Accessing Android’s Sensors
Introduction
What is Android ?
 Android is a software stack for mobile
devices that includes an operating system,
middleware and key applications. The
Android SDK provides the tools and APIs
necessary to begin developing applications
on the Android platform using the Java
programming language
Created by
 On the 5th of November 2007. the Open Handset Alliance, a
consortium of several companies which include
Texas Instruments, Broadcom Corporation, Google, HTC, Intel,
LG (Optimus One), Marvell Technology Group, Motorola, Nvidia,
Qualcomm, Samsung Electronics, Sprint Nextel and T-Mobile
was unveiled with the goal to develop open standards for mobile
devices.[5] Along with the formation of the Open Handset
Alliance, the OHA also unveiled their first product, Android, a
mobile device platform built on the Linux kernel version 2.6.[5]
 In July 2005, Google acquired Android Inc., a small startup
company based in Palo Alto, California, USA
Introduction(cont.)

 MiddlewareLibraries (i.e. SQLite, OpenGL, WebKit, etc)


 Android Runtime (Dalvik Virtual Machine and core libraries)
 Application FrameworkAbstraction for hardware access; manages
application resources and the UI; provides classes for developing
applications for Android

 Applications Native apps: Contacts, Phone, Browser, etc.


 Third-party apps: developer’s applications.
Introduction (cont.)

 What you need:Operating System: Microsoft


Windows (>= XP), Mac OS X >= 10.4.8, Linux
 Android SDK
 JDK >= 5

 Android Development with Eclipse:Eclipse (+


Java Development Tools plug-in and Web Tools
Platform) + Android Development Tools plug-in
Introduction (cont.)

 Design Considerations:Low processing speedOptimize code to run


quick and efficiently

 Limited storage and memoryMinimize size of applications; reuse and


share data

 Limited bandwidth and high latencyDesign your application to be


responsive to a slow (sometimes non-existent), intermittent network
connection

 Limited battery lifeAvoid expensive operations

 Low resolution, small screen size“Compress” the data you want to


display
Application Components and
Lifecycle

 Application Components and Lifecycle


 Components of your application:ActivitiesPresentation
layer for the application you are building
 For each screen you have, their will be a matching Activity
 An Activity uses Views to build the user interface

 ServicesComponents that run in the background


 Do not interact with the user
 Can update your data sources and Activities, and trigger
specific notifications
 Components of your application:Content
ProvidersManage and share application databases

 IntentsSpecify what intentions you have in terms of a


specific action being performed

 Broadcast ReceiversListen for broadcast Intents that


match some defined filter criteria
 Can automatically start your application as a response
to an intent
 Application LifecycleTo free up resources, processes
are being killed based on their priority:Critical Priority:
foreground (active) processesForeground activities;
components that execute an onReceive event handler;
services that are executing an onStart, onCreate, or
onDestroy event handler.

 High Priority: visible (inactive) processes and started


service processesPartially obscured activity (lost
focus); services started.

 Low Priority: background processesActivities that are


not visible; activities with no started service
Application Components and
Lifecycle (cont.)

 Activity Lifecycle: Activities are managed as


an activity stack (LIFO collection)
 Activity has four states:Running: activity is in the
foreground
 Paused: activity has lost focus but it is still visible
 Stopped: activity is not visible (completely
obscured by another activity)
 Inactive: activity has not been launched yet or has
been killed.
User Interfaces

 LayoutsSpecify the position of child views (controls) on the


screen
 Common Layout Objects:FrameLayout: all child views are
pinned to the top left corner of the screen
 LinearLayout: each child view is added in a straight line
(vertically or horizontally)
 TableLayout: add views using a grid of rows and columns
 RelativeLayout: add views relative to the position of other
views or to its parent.
 AbsoluteLayout: for each view you add, you specify the
exact screen coordinate to display on the screen
User Interfaces (cont.)

 MenusConcerned about having to much


functionality on the screen => use menus
 Three menu types:Icon Menu: appears at the bottom
of the screen when the user presses the Menu button.
It can display icons and text for up to six menu items.
 Expanded Menu: displays a scrollable list of menu
items not previously displayed in the icon menu.
 Submenu: displayed as a floating window.
Data Storage
 Different techniques for saving data:Shared Preferences: lightweight mechanism to
store a known set of key-value pairsUseful for saving user preferences, application
settings, and user interface state

 SQLite Databases: relational database library for storing and managing complex
dataResults from database queries are stored in Cursors
 Look at SQLiteOpenHelper and Cursor class
 More Info: http://www.sqlite.org/

 Files: you can create, write, and read files from the local storage or external media (SD
Cards)Look at FileOutputStream, FileInputStream, and Resources classes.

 Content ProvidersMechanism for sharing data between applications by abstracting the


underlying data source
 Access is handled through a URI model
 Native Android Content Providers
Background Services

 Services run in the background


 Primarily used for:Updating Content Providers
 Firing Intents
 Triggering Notifications
 Any operation that does not necessitate user interaction
(i.e. networking, MP3 playback)

 For intensive and/or blocking operations, the service


should be run in its own thread
Background Services (cont.)

 Creating and Controlling ServicesCreate a Service:Extend


the Service class; override specific methods (such as
onCreate, onStart, onBind, etc).

 Start and stop a Service:Use the startService method from


inside your current Activity class
 Use the stopService method from inside your current
Activity class

 If the phone becomes inactive while you have services


running, those services will not work properly (freeze)Stop
your phone from going into sleep mode
Location-Based Services

 Selecting a Location ProviderTo determine your


current location, Android can use several technologies
(or Location Providers)GPS Provider – determines
location using satellites
 Network Provider – determines location using cell
towers and Wi-Fi access points

 Each provider has a set of criteria (power


consumption, cost, response time, accuracy, etc.)
under which it may be used
GPS Devices having Android
Location-Based Services
(cont.)

 GeocodingForward Geocoding: finds latitude and longitude of an


addressUse method getFromLocationName from the Geocoder class

 Reverse Geocoding: finds the street address for a given latitude and
longitudeUse method getFromLocation from the Geocoder class

 Map-Based ActivitiesClasses that support Android maps:MapView: a


view which displays a map. Used within a MapActivity
 MapActivity: manages all that is required for displaying a map
 Overlay: used for annotating maps (i.e. drawing text on the map)
 MapController: used for panning and zooming
 MyLocationOverlay: used to display the current position and
orientation of the device
Default map view
Accessing Android’s Sensors

 The SensorManager is used to manage the sensor hardware


available on an Android device:
 SensorManager sensorManager =
(SensorManager)getSystemService(Context.SENSOR_
SERVICE);
 Monitoring changes in sensor values:

 SensorListener sensorListener = new SensorListener() {


 public void onSensorChanged(int sensor, float[] values) { … }
 }
 The values depend on the type of sensor (i.e. accelerometer, light,
magnetic field, temperature, proximity)
The End

You might also like