Google s Android: An Overview



Similar documents
Android For Java Developers. Marko Gargenta Marakana

Lecture 1 Introduction to Android

Android Development. Marc Mc Loughlin

Android for Java Developers OSCON Marko Gargenta Marakana

Android Basics. Xin Yang

Creating and Using Databases for Android Applications

Hello World! Some code

Android Fundamentals 1

Introduction to Android

An Introduction to Android Application Development. Serdar Akın, Haluk Tüfekçi

Introduction to Android: Hello, Android! 26 Mar 2010 CMPT166 Dr. Sean Ho Trinity Western University

An Introduction to Android

Chapter 2 Getting Started

Introduction to Android. CSG250 Wireless Networks Fall, 2008

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

directory to "d:\myproject\android". Hereafter, I shall denote the android installed directory as

Deep Inside Android. OpenExpo Zurich September 25 th, Gilles Printemps - Senior Architect. Copyright 2007 Esmertec AG.

Android Geek Night. Application framework

How To Develop Android On Your Computer Or Tablet Or Phone

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

Mobile Applications Grzegorz Budzyń Lecture. 2: Android Applications

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

4. The Android System

Android 多 核 心 嵌 入 式 多 媒 體 系 統 設 計 與 實 作

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

Praktikum Entwicklung Mediensysteme (für Master)

Mobile Application Development

Building an Android client. Rohit Nayak Talentica Software

Università Degli Studi di Parma. Distributed Systems Group. Android Development. Lecture 2 Android Platform. Marco Picone

An Introduction to Android. Huang Xuguang Database Lab. Inha University

Hacking your Droid ADITYA GUPTA

Q1. What method you should override to use Android menu system?

Технологии Java. Android: Введение. Кузнецов Андрей Николаевич. Санкт-Петербургский Государственный Политехнический Университет

TUTORIALS AND QUIZ ANDROID APPLICATION SANDEEP REDDY PAKKER. B. Tech in Aurora's Engineering College, 2013 A REPORT

INTRODUCTION TO ANDROID CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 11 02/15/2011

CS378 -Mobile Computing. Android Overview and Android Development Environment

Android Application Development. Daniel Switkin Senior Software Engineer, Google Inc.

A Short Introduction to Android

What else can you do with Android? Inside Android. Chris Simmonds. Embedded Linux Conference Europe Copyright 2010, 2net Limited.

Graduate presentation for CSCI By Janakiram Vantipalli ( Janakiram.vantipalli@colorado.edu )

Android Concepts and Programming TUTORIAL 1

Overview of CS 282 & Android

Introduction to Android

Frameworks & Android. Programmeertechnieken, Tim Cocx

MMI 2: Mobile Human- Computer Interaction Android

Android Programming and Security

Mobile Application Development 2014

App Development for Smart Devices. Lec #2: Android Tools, Building Applications, and Activities

Android Application Development

Introduction to Android Programming (CS5248 Fall 2015)

Android. Learning Android Marko Gargenta. Tuesday, March 11, 14

Android Application Development - Exam Sample

Programming the Android Platform. Logistics

Android app development course

Università Degli Studi di Parma. Distributed Systems Group. Android Development. Lecture 1 Android SDK & Development Environment. Marco Picone

Table of Contents. Adding Build Targets to the SDK 8 The Android Developer Tools (ADT) Plug-in for Eclipse 9

Smartphone market share

Android Framework. How to use and extend it

Android Architecture. Alexandra Harrison & Jake Saxton

ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

Specialized Android APP Development Program with Java (SAADPJ) Duration 2 months

Programming with Android

DEVELOPING MOBILE APPLICATIONS USING ANDROID

06 Team Project: Android Development Crash Course; Project Introduction

Android Security Lab WS 2014/15 Lab 1: Android Application Programming

App Development for Android. Prabhaker Matet

Android Development. Lecture AD 0 Android SDK & Development Environment. Università degli Studi di Parma. Mobile Application Development

Basics. Bruce Crawford Global Solutions Manager

Development. SriSeshaa Technologies. Table of Contents

Example of Standard API

Programming Android Smart Phones. Tom Chothia Internet Computing Workshop

Developer's Cookbook. Building Applications with. The Android. the Android SDK. A Addison-Wesley. James Steele Nelson To

Basics of Android Development 1

UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

BEGIN ANDROID JOURNEY IN HOURS

AndroLIFT: A Tool for Android Application Life Cycles

ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

Mobile Phones Operating Systems

How to develop your own app

Android Application Development: Hands- On. Dr. Jogesh K. Muppala

Getting Started: Creating a Simple App

ANDROID. Programming basics

An Android-based Instant Message Application

The power of root on Android emulators

ITG Software Engineering

l What is Android? l Getting Started l The Emulator l Hello World l ADB l Text to Speech l Other APIs (camera, bitmap, etc)

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

Now that we have the Android SDK, Eclipse and Phones all ready to go we can jump into actual Android development.

Android Application Model

Reminders. Lab opens from today. Many students want to use the extra I/O pins on

Android Operating System

Getting started with Android and App Engine

ANDROID BASED MOBILE APPLICATION DEVELOPMENT and its SECURITY

Login with Amazon Getting Started Guide for Android. Version 2.0

ODROID Multithreading in Android

Introduction to Android SDK Jordi Linares

Android Introduction. Hello Mihail L. Sichitiu 1

Developing NFC Applications on the Android Platform. The Definitive Resource

Mobile Security - Tutorial 1. Beginning Advanced Android Development Brian Ricks Fall 2014

Transcription:

Google s Android: An Overview Yoni Rabkin yonirabkin@member.fsf.org This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 1

Abstract This lecture is an overview of developing applications for Google s Android. We start by introducing Android and its components, we look at the anatomy of an Android application, we explain basic components of the Android application API including UI design and finally we say some things about the development environment. This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 2

Should I be giving this lecture? I should because I... wrote one Android application from start to finish I shouldn t because I... wrote only one Android application from start to finish don t know Java don t use Eclipse This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 3

Legal Stuff Portions of this work are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 4

What is Android? Android is a bunch of software (a) released by Google and the Open Handset Alliance (b). (a) platform blah blah framework blah blah (b) The alliance includes diverse members such as: China Mobile, Asus, T-Mobile (U.S.), Softbank Mobile (Japan), Motorola, Samsung, etc. This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 5

What isn t Android? any specific piece of hardware written entirely in Java runs only Java This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 6

What does Android include? Linux Kernel (2.6) + drivers Android Runtime: core libraries + Dalvik virtual machine Libraries: OpenGL, SGL (a), Freetype, SSL, Sqlite, Webkit, libc XManager where X is some API component Pre-built and packaged applications: Contacts, Phone, Browser, Calendar, etc. (b) Android SDK (a) 2D graphics (b) http://source.android.com/ This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 7

The Dalvik Virtual Machine The Dalvik virtual machine... is a register-based Java VM is memory efficient is designed to run multiple VMs efficiently (one per application) (a) has no Just In Time compilation uses special byte-code relies on the Linux kernel for low-level stuff like threading (a) communication via AIDL (Android Interface Definition Language) This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 8

Low-level Libraries BSD-derived libc tuned for small devices PacketVideo s OpenCore multimedia code (a) which supports: MPEG4, H.264, MP3, OGG, AAC, AMR, JPG, and PNG (b) libwebcore: Webkit based library to support the browser and web-views 3D support for hardware or software rendering via OpenGL Freetype font rendering Sqlite: relational database for application use (a) http://www.packetvideo.com/products/core/index.html (b) PNG is the standard for applications This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 9

App Anatomy: file structure Selected files from a simple Android application structure../androidmanifest.xml./build.xml./bin/work.apk./bin/classes/deliverator/foo/work.class./bin/classes/deliverator/foo/r.class./res/layout/main.xml./res/layout/setup.xml./res/values/theme.xml./res/values/strings.xml./res/drawable/background.png./res/drawable/overlay.png./src/deliverator/foo/r.java./src/deliverator/foo/work.java This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 10

App Anatomy: file structure detail Android can infer which resource to load by directory structure../res/values-en/strings.xml./res/values-fr/strings.xml..for languages or..../res/drawable-en-rus-finger/./res/drawable-port/./res/drawable-port-160dpi/./res/drawable-qwerty/...for layouts and graphics, which can lead to..../res/drawable-en-rus-port-160dpi-...-qwerty-dpad-480x320/ This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 11

App Anatomy: AndroidManifest.xml AndroidManifest.xml is an essential part of the application because it (amongst other things): names the Java package for the application describes activities, services, content providers, etc. declares permissions the application must have declares the minimum Android API level declares Intents This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 12

App Anatomy: Intents Intents convey requests between all different components of the system. The Intent Resolution mechanism revolves around matching an Intent against all of the <intent-filter> descriptions in the installed applications and BroadcastReceivers. (a) defined in AndroidManifest.xml or dynamically belong to an Activity or BroadcastReceiver can deliver data via RFC2396 URIs (a) multiple intents all get called! This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 13

Intents: Code Example AndroidManifest.xml < a c t i v i t y android : name= ". Work "... > < i n t e n t f i l t e r > < a c t i o n android : name= " android. i n t e n t. a c t i o n. MAIN" / > < a c t i o n android : name= " android. i n t e n t. a c t i o n.sendto" / > <category android : name= " android. i n t e n t. category.default" / > <data android : scheme= " smsto " / >... Work.java I n t e n t i n t e n t = g e t I n t e n t ( ) ; S t r i n g a c t i o n = i n t e n t. getaction ( ) ; i f ( I n t e n t. ACTION \_SENDTO. equals ( a c t i o n ) ) { d o S t u f f ( i n t e n t. getdata ( ). getencodedschemespecificpart ( )... This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 14

Activities An activity presents a visual user interface for a single task. always a subclass of the Activity base class one application, many activities one activity calls another (stack) (a) given a default window to draw in visual content defined by Views have a life-cycle (a) An activity can return a value on exit, but doesn t have to. This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 15

Activities: Code Example Suppose that your application has a message composition screen. This is an Activity. The UI would be implemented in its own file, say: src/blah/blooey/compose.java: public class Compose extends A c t i v i t y { @Override public void oncreate ( Bundle savedinstancestate ) { super. oncreate ( savedinstancestate ) ; setcontentview (R. l a y o u t. main ) ;... This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 16

Activities Life-Cycle: Code Example Activities call one another, so our Compose activity would need to define what to do if it gets interrupted, calls another activity or gets called: @Override protected void onresume ( ) { super. onresume ( ) ; dosomething ( ) ; } @Override protected void onpause ( ) { super. onpause ( ) ; dosomethingelse ( ) ; } protected void ondestroy ( ) {... } protected void onstop ( ) {... } This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 17

Threads Activity UI and your code run in the same process. So non-trivial computations require a separate thread. f i n a l Handler mhandler = new Handler ( ) ; f i n a l Runnable mupdateresults = new Runnable ( ) {... public void run ( ) { updateresultsinui ( ) ; } } ; Thread t = new Thread ( ) { public void run ( ) { mresults = dosomethingheavy ( i n p u t ) ; mhandler. post ( mupdateresults ) ; } } ; t. s t a r t ( ) ;... private void updateresultsinui ( ) { i f ( mresults == Something ) { updateui ( mresults ) ; } } This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 18

Services A service runs in the background for an indefinite period of time. A service is like an Activity without a UI. examples: getting data from the network, playing a video an activity can start a service starts explicitly with Context.startService(intent) starts implicitly with Context.bindService(intent) provides a callback via its onbind() method. runs until Context.stopService() or stopself() This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 19

Broadcast receivers A broadcast receives and reacts to broadcast announcements. one application, many broadcast receivers always a subclass of BroadcastReceiver base class example broadcasts: low battery, call incoming, sms arrives etc. can start an activity or the NotificationManager as fickle and subtle as any asynchronous process is (a) (a) example: registering and unregistering in onresume() and onpause() This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 20

Broadcast receivers: Code Example in some service of the system: I n t e n t i n t e n t = new I n t e n t (SOMEACTION) ; i n t e n t. putextra ( "name", " value " ) ; sendbroadcast ( i n t e n t ) ;...then in the app: private BroadcastReceiver r e c e i v e r = new BroadcastReceiver ( ) public void onreceive ( Context context, I n t e n t i n t e n t ) { S t r i n g value = i n t e n t. g e t S t r i n g E x t r a ( "name" ) ; SomeActivityMethod ( value ) ; This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 21

Content providers A content provider makes an application s data available to other applications. data can be from files, sqlite DB or anything else (a) always a subclass of ContentProvider base class use a ContentResolver object and call its methods (a) preferences are lightweight name-value storage This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 22

Content providers: Code Example S t r i n g [ ] p r o j e c t i o n = new S t r i n g [ ] { People. \ _ID, People. \ _COUNT, People.NAME, People.NUMBER} ; U r i contacts = People.CONTENT\ _URI ; Cursor managedcursor = managedquery ( contacts, p r o j e c t i o n, null, null, People.NAME + " ASC" ) ; managedcursor and managedquery manage the cursor life-cycle for you. This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 23

UI: somelayout.xml Stack some layouts with widgets in boxes: <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/sometext" android:text="@string/howareyougentlemen" android:layout_width="fill_parent" android:layout_height="wrap_content" />... This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 24

UI: SomeActivity.java Call the layout and connect to the widgets: public void setsometext ( S t r i n g t e x t ) { TextView somewidget = ( TextView ) findviewbyid (R. i d. sometext ) ; somewidget. settext ( t e x t ) ; } This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 25

UI: gefingerpoken und mittengrabben Find a button in the layout and connect it to a listener: f i n a l Button somebutton = ( Button ) findviewbyid (R. i d. somebutton ) ; somebutton. s e t O n C l i c k L i s t e n e r (new O nclicklistener ( ) { public void onclick ( View v ) { dosomething ( ) ; } } ) ; This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 26

The Development environment Eclipse (a) is the natural environment for developing Android applications. However, real editors can be also used if you are a real programmer. The Android SDK integrates into Eclipse and helps the otherwise addled programmer write code. There are different versions of the SDK (1.0, 1.1, 1.5) (b) Three important command line tools: "android", "emulator" and "adb" (a) I tried to load Eclipse for this lecture... it s still loading. (b) at the time of writing This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 27

tools/android An avd is an Android Virtual Device. Use tools/android to create, list, modify and remove avds. $./android create avd -t 3 -n "1.5lvl3" \ --sdcard /path/to/disk/image $./android list Name: 1.5lvl3 Path: /home/foo/.android/avd/1.5lvl3.avd Target: Google APIs (Google Inc.) Based on Android 1.5 (API level 3) Skin: HVGA Sdcard: /path/to/disk/image This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 28

tools/emulator and the Console The emulator runs a virtual Android device. $./emulator @1.5lvl3 Once the emulator is running, the Console (optionally) connects to an emulator instance and can issues commands or retrieve status. $ telnet localhost 5554 Android Console: type help OK This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 29

Console Examples Example Console commands: geo nmea GPGGA,123519,4807.038,N,01131.000,E... redir add tcp:5000:5554 power display/ac/status/present/health/capactiy network delay gprs/edge/umts/none network speed gsm/hscsd/gprs/.../full gsm call/accept/busy/.../list/voice/status sms send... Also from the command line: $./emulator -netspeed gprs This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 30

tools/adb aka Android Debug Bridge The Android Debug Bridge connects to a device or emulator. $./adb -s HT93LLZ00513 shell $./adb -s HT93LLZ00513 install /path/app.apk... or connect to the device logs (a) adb # logcat I/DEBUG(551): debuggerd: Apr 21 2009 I/vold (550): Android Volume Daemon...... or connect to the device s sqlite DB # sqlite3 SQLite version 3.5.9 sqlite> (a) useful with Log.X(TAG, info) This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 31

Publishing Publishing allows others to install your software. Publishing includes: sign the application (not with the debug key) (a) version the app: android:versioncode="2" and android:versionname="1.1" (b) provide android:label="@string/app_name" and android:icon="@drawable/icon" turn off debugging/logging, compile, sign and test upload to the Android market (a) same signature: permissions and upgrades made easy (b) accessible via: getpackageinfo(java.lang.string, int) This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 32

Getting the Source The source (about 2GB) is hosted at http://source.android.com/, using Repo (some Python) and Git. This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 33

References and Adieu http://developer.android.com/ http://android-developers.blogspot.com/ http://groups.google.com/group/android-beginners http://groups.google.com/group/android-developers Happy Hacking This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/. p. 34