Android - University of Engineering and Technology, Lahore · ICOSST 2010 Android Presentation...
Transcript of Android - University of Engineering and Technology, Lahore · ICOSST 2010 Android Presentation...
Android
An emerging OS for mobile devices
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Agenda
• What is an android? (Part 1)
• Inside Android (Components) (Part 2)
• Writing code for android devices.(Part 3)
• Demonstration (Part 4)
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
What is an Android? (Part 1)
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
About Android (Cont…)
• The word “android” literally means a robot. • Android is an OS for the mobile devices. • Android is more than an OS ,it’s complete
software stack. • Mainly developed by Google • Product of Open Handset Alliance • Based on linux kernel • Ranked 1st in sales of smart devices. • 100,000 apps freely available for Android. • Code written in Java language.
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
About Android
• We can create powerful java applications in android.
• Android phones are called smart mobile devices. • Android has a potential market beyond mobile
devices. • Some of android code being written for non
mobile applications. • Android was made freely available under Apache
open source license in Oct 2008. • Estimated 3 billion users
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
HTC G1
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Features
• Connectivity: WIFI, Bluetooth and GPRS, EDGE, and 3G Hardware: Support for GPS, accelerometers and Cameras.
• Graphics: Built in 2D/3D support including OpenGL.
• Storage: SQLLite • Browser: The web browser is based on Webkit • Supports modern features like multi touch and
multi tasking.
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Popular version
Version Name
1.5 Cupcake (Linux 2.6.27)
1.6 Donut (Linux 2.6.29)
2.0/2.1 Éclair (Linux 2.6.29)
2.2 Froyo (Linux 2.6.32)
2.3 Gingerbread (Linux 2.6.35.7)
3.0/2.4 Honeycomb (2011)
3x/2x Ice Cream (2011)
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
OS trends • Android popularity is growing and will soon
challenge Symbian in 2014 [Gartner.com]
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Inside Android Platform (Part 2)
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Application Architecture
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Inside Android Platform
• Linux Kernel
• Native Libraries
• Android Runtime
• Application Framework
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Detailed components
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Android Manifest
• Every application must provide a file named “AndroidManifest.xml “
• Contains the configuration information for correctly installing it.
• Contains three things
1. Class names
2. Events
3. Permissions
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Developing Applications with Android (Part 3)
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Tools Needed
• To develop android applications we need
• IDE: Officially Eclipse is used
• Android SDK
• Android Developer Tools plug-in for Eclipse
• Java Coding in eclipse is very intitutive, provides rich java environment like context sensitive help and code suggestions
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Android SDK
• Provides tools and APIs to begin developing applications on the Android using JAVA.
• Used to build, compile, test and debug user applications
• Can be downloaded for Linux, Windows and MAC.
• We can add, delete and update components in android SDK.
• To begin development we need Eclipse IDE with ADT plug-in.
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Anatomy of an Android application
Creating and Deploying android application
• Activity
• Service
• Content Provider
• Processes and Tasks.
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Bruce Scharlau, University of Aberdeen, 2010
Android applications have common structure
Broadcast receivers can trigger intents that start an application
Data storage provide data for your apps, and can be shared between apps – database, file, and shared preferences (hash map) used by group of applications
Services run in the background and have no UI for the user – they will update data, and trigger events
Intents specify what specific action should be performed
Activity is the presentation layer of your app: there will be one per screen, and the Views provide the UI to the activity
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Bruce Scharlau, University of Aberdeen, 2010
Android applications have common structure
Views such as lists, grids, text boxes, buttons, and even an embeddable web browser
Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data
A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files
A Notification Manager that enables all apps to display custom alerts in the status bar
An Activity Manager that manages the life cycle of applications and provides a common navigation backstack
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
How it works
Bruce Scharlau, University of Aberdeen, 2010
Write app in Java
Compiled in Java
Transformed to Dalvik bytecode
Linux OS
Loaded into Dalvik VM
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
HelloWorld Android
package com.google.android.helloactivity; import android.app.Activity; import android.os.Bundle; public class HelloActivity extends Activity { public HelloActivity() { } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.hello_activity); } }
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Can assume that most have android 2.1 or 2.2
Bruce Scharlau, University of Aberdeen, 2010 http://developer.android.com/resources/dashboard/platform-versions.html
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
• Applications can be run on the device or emulator.
Bruce Scharlau, University of Aberdeen, 2010
Emulator Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Bruce Scharlau, University of Aberdeen, 2010
There is a common file structure for applications
code
images
files
UI layouts
constants
Autogenerated resource list
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Bruce Scharlau, University of Aberdeen, 2010
The AndroidManifest lists application details
<?xml version="1.0" encoding="utf-8"?> <manifest
xmlns:android="http://schemas.android.com/apk/res/android" package="com.my_domain.app.helloactivity"> <application android:label="@string/app_name"> <activity android:name=".HelloActivity"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category
android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application>
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Dalvik Virtual Machine
• Responsible for running android Java programs.
• Optimized for low memory.
• Designed to allow multiple VM instances to run.
• Relies on OS for process isolation, memory management and threading.
• Executes Dalvik(DEX) files
• DEX files are zipped into android package (APK)
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Android vs IPhone
• Android is open source but iOS is proprietary. • iOS can only be used on apple machines like
Iphone,Ipad,Ipod • Android has a universe of diverse mobile devices
manufactured by renowned OEMS.For e.g. HTC,Samsung,LG,Sony Ericsson,Dell
• e.g Iphone iOS development is restricted while Android is flexible.
• iOS uses objective C while Android uses wildly adopted Java language.
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Bruce Scharlau, University of Aberdeen, 2010
There are lots of sources of information
• The sdk comes with the API references, sample applications and lots of docs
• Blog http://android-developers.blogspot.com/ which has lots of useful examples, details
• There is http://www.anddev.org
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Demonstration
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
ICOSST 2010 Android Presentation
Questions?
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010