ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

Similar documents
ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

Android Architecture. Alexandra Harrison & Jake Saxton

Lecture 1 Introduction to Android

Praktikum Entwicklung Mediensysteme (für Master)

A Short Introduction to Android

ANDROID BASED MOBILE APPLICATION DEVELOPMENT and its SECURITY

Overview of CS 282 & Android

Creating and Using Databases for Android Applications

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

Here to take you beyond Mobile Application development using Android Course details

An Introduction to Android

ITG Software Engineering

Introduction to Android

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

ANDROID OPERATING SYSTEM

Getting Started with Android Programming (5 days) with Android 4.3 Jelly Bean

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

Android Development. Marc Mc Loughlin

Android Fundamentals 1

ANDROID INTRODUCTION TO ANDROID

Android Basics. Xin Yang

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

Mobile Application Development 2014

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

Android Operating System

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

Android Geek Night. Application framework

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

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

Programming the Android Platform. Logistics

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

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

Overview. The Android operating system is like a cake consisting of various layers.

UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

Introduction to Android Programming (CS5248 Fall 2015)

Android Application Development - Exam Sample

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

Frameworks & Android. Programmeertechnieken, Tim Cocx

Android Developer Fundamental 1

Introduction to Android

Getting started with Android and App Engine

The Android Platform

Mobile Phones Operating Systems

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

INTERMEDIATE ANDROID DEVELOPMENT Course Syllabus

Lecture 17: Mobile Computing Platforms: Android. Mythili Vutukuru CS 653 Spring 2014 March 24, Monday

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

Example of Standard API

A Look through the Android Stack

CS378 -Mobile Computing. Android Overview and Android Development Environment

ANDROID PROGRAMMING - INTRODUCTION. Roberto Beraldi

Synthesis for Developing Apps on Mobile Platforms

Android (Basic + Advance) Application Development

Introduction to Android Development. Jeff Avery CS349, Mar 2013

Hacking your Droid ADITYA GUPTA

Mobile Operating Systems. Week I

Introduction to Android. CSG250 Wireless Networks Fall, 2008

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

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

Jordan Jozwiak November 13, 2011

[PACKTl. Flash Development for Android Cookbook. Flash, Flex, and AIR. Joseph Labrecque. Over 90 recipes to build exciting Android applications with

Workshop on Android and Applications Development

COURSE CONTENT. GETTING STARTED Select Android Version Create RUN Configuration Create Your First Android Activity List of basic sample programs

Mobile Applications Grzegorz Budzyń Lecture. 2: Android Applications

Building an Android client. Rohit Nayak Talentica Software

Analysis of advanced issues in mobile security in android operating system

1. Introduction to Android

Research and Design of Universal and Open Software Development Platform for Digital Home

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

JavaFX Session Agenda

GETTING STARTED WITH ANDROID DEVELOPMENT FOR EMBEDDED SYSTEMS

Google Android Syllabus

Mobile applications security Android OS (case study) Maciej Olewiński. Cryptographic Seminar r.

Mobile Application Development Android

imaginea white paper

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

Android Application Development

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

Programming with Android

PROFILEDROID: MULTI-LAYER PROFILING OF ANDROID APPLICATIONS XUETAO WEI LORENZO GOMEZ UNIVERSITY OF CALIFORNIA, RIVERSIDE PROFESSOR IULIAN NEAMTIU

Mocean Android SDK Developer Guide

Developing NFC Applications on the Android Platform. The Definitive Resource

CS 528 Mobile and Ubiquitous Computing Lecture 2: Android Introduction and Setup. Emmanuel Agu

Priority Based Pre-emptive Task Scheduling for Android Operating System

Mobile Devices - An Introduction to the Android Operating Environment. Design, Architecture, and Performance Implications

How To Develop An App For Ios (Windows)

Android Mobile App Building Tutorial

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

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

The power of root on Android emulators

Android Programming and Security

4 Application Development

Presenting Android Development in the CS Curriculum

ODROID Multithreading in Android

Practical Android Projects Lucas Jordan Pieter Greyling

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

Android Operating System:

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

Introduction to Android SDK Jordi Linares

4. The Android System

Transcription:

ANDROID PROGRAMMING - INTRODUCTION Roberto Beraldi

Introduction Android is built on top of more than 100 open projects, including linux kernel To increase security, each application runs with a distinct system identity (linux UID and GID) Application are isolated from each other Use a quite efficient IPC mechanism To facilitate resource access from isolated application, android exploit a permission-based security mechanism Each application needs permission to access system resources Permissions are granted at installation time There are 130 resources (android 4.2)

Android architecture Kernel Linux Set of drivers The kernel provides preemptive multitasking,low level core system services, like Memory,power,process management. Network stack, device drivers (e.g. for display)

Android architecture Dalvik VM Specific Libraries This is a set of libraries used predominantly for interacting directly with an instance of the Dalvik VM and is unlikely to be used by most Android application developers. Dalvik VM: similar to the JVM Designed by Google more efficient than JVM in terms of memory usage, designed to run under resource constraints Act as a sandbox: each application runs inside a DVM.dex format has footprint 50% smaller

Android architecture Java Interoperability Libraries are an open source implementation (based on the Apache Harmony project) of a subset of the Standard Java core libraries that have been adapted and transformed for use by applications running within a Dalvik VM.. Android Libraries This category encompasses those Java-based libraries that are specific to Android development. Examples of libraries in this category include the application framework libraries in addition to those that facilitate user interface building, graphics drawing and database access.

Android libraries android.app Provides access to the application model and is the cornerstone of all Android applications. android.content Facilitates content access, publishing and messaging between applications and application components. android.database Used to access data published by content providers and includes SQLite database management classes. android.graphics A low-level 2D graphics drawing API including colors, points, filters, rectangles and canvases. android.hardware Presents an API providing access to hardware such as the accelerometer and light sensor. android.opengl A Java interface to the OpenGL ES 3D graphics rendering API. android.os Provides applications with access to standard operating system services including messages, system services and inter-process communication. android.media Provides classes to enable playback of audio and video. android.net A set of APIs providing access to the network stack. Includes android.net.wifi, which provides access to the device s wireless stack. android.provider A set of convenience classes that provide access to standard Android content provider databases such as those maintained by the calendar and contact applications. android.text Used to render and manipulate text on a device display. android.util A set of utility classes for performing tasks such as string and number conversion, XML handling and date and time manipulation. android.view The fundamental building blocks of application user interfaces. android.widget - A rich collection of pre-built user interface components such as buttons, labels, list views, layout managers, radio buttons etc. android.webkit A set of classes intended to allow web-browsing capabilities to be built into applications.

Android architecture Surface Manager: Rendering of Views 2D graphics Media Framework: Manage different codec, e.g. mp3,h.264,mpeg4,etc. Rendering of Font types In process DB Open GL ES 2D and 3D graphics For Embedded systems Web engine C standard library Many are wrappers of library written in C/C++

Android architecture Application framework: Set of managers wrapping the native libraries, make them accessible to the programmer

Android frameworks (not complete list) Activity Manager Controls all aspects of the application lifecycle and activity stack. Content Providers Allows applications to publish and share data with other applications. Resource Manager Provides access to non-code embedded resources such as strings, color settings and user interface layouts. Notifications Manager Allows applications to display alerts and notifications to the user. View System An extensible set of views used to create application user interfaces. Package Manager The system by which applications are able to find out information about other applications currently installed on the device. Telephony Manager Provides information to the application about the telelphony services available on the device such as status and subscriber information. Location Manager Provides access to the location services allowing an application to receive updates about location changes.

Android architecture Application layer

Characteristics of android applications User interaction touch screen based UI interface Variable screen size From low, medium, high (smart TV) Resource usage is an issue but.. Sensors Position, orientation, magnetic field, light sensor,.. Portable Context-awareness based applications (what s around me, where are my friends, )

Bird s eye view to application architecture User Interface Activity Fragment UI runs in a thread Main thread it should respond fast responsiveness Computation AsyncTask Local service Remote service Broadcast receiver Separate thread Need mechanism to interact with UI Implements the business logic Data Preference File SQLite Network Content provider Many ways to store data

What an application is composed of? SW component. Resources + apk Manifest File

What an application is composed of? Software components Activity Fragment Service Broadcast receiver Content provider Intent Resources Pictures, video, audio file, etc. Accessed via an ID Accessed via a manager.

Android applications Every application runs in its own linux process (receivers its own User ID) A process is created when a component of the application needs to be run An unusual feature of Android is that an application process s lifetime is not directly controlled by the application (more on this soon) For example, if the application is temporary not visible the system may decide to kill the process

Software components - activity User Interface Activity The simplest application is composed of a single activity that inflates a UI, defined by an XML file (some similarity with HTML) An activity is an event-triggered software component staying behind a UI and managed by the operating system via callbacks or hooks It also reacts to user generated events coming from UI via handlers (e.g., push a button)

Software components -activity User Interface The response time of an activity should be small (<5s) otherwise the ANR message appears Multithreading is required to do slow work in background Activity Activity

Software components - activity An Activity has a state, {running, paused, stop} The system can kill an activity in the pause or stop state to reclaim resources To assure consistency when a killed activity restarts, user may implement callback methods to manage the information that must persist These methods are called before killing or restarting the activity RUNNING STOP KILLED RUNNING

Software components - activity User Interface User Interface Activity INTENT Activity Usually, inside an application one activity is marked as MAIN (in the manifest file) and launched when a user touches the launching icon in the Home screen Activities However, an activity A can start another activity B

Software components - Intent User Interface User Interface Matching Filter Activity INTENT Intent Activity The activity can start another activity using a mechanism based on Intent and Filters An intent is a message directed either explicitly to another activity (by class name), or implicitly to any activity whose filter matches the intent s action and data

Software components - Intent User Interface User Interface Matching Filter Activity INTENT Intent Activity An Intent contains in fact the action to be performed and optionally data upon which to work The task of finding the right activity that can perform the action is called intent resolution

Broadcast intent System wide intent received by special component named broadcast receivers that has been registered with the intent Low battery Chage in connectivity Etc.. Asynchronous transmission Ordered transmission in that it is sent to one receiver at a time where it can be processed and then either aborted or allowed to be passed to the next Broadcast Receiver.

Broadcast receiver Broadcast Receivers are the mechanism by which applications are able to respond to Broadcast Intents. A Broadcast Receiver must be registered by an application and configured with an Intent Filter to indicate the types of broadcast in which it is interested. When a matching intent is broadcast, the receiver will be invoked by the Android runtime regardless of whether the application that registered the receiver is currently running. The receiver then has 5 seconds in which to complete any tasks required of it (such as launching a Service, making data updates or issuing a notification to the user) before returning. Broadcast Receivers operate in the background and do not have a user interface.

Software comp broadcast receiver No UI Broadcast intent Filter Broadcast receiver Receive and react to broadcast announcement, or broadcast intents BOOT_COMPLETED.. It may start an activity, a service, or it may use the notification service to alert the user

Services Android Services are processes that run in the background and do not have a user interface. They can be started and subsequently managed from Activities, Broadcast Receivers or other Services. Android Services are ideal for situations where an application needs to continue performing tasks but does not necessarily need a user interface to be visible to the user.

Services Although Services lack a user interface, they can still notify the user of events through the use of notifications and toasts (small notification messages that appear on the screen without interrupting the currently visible Activity) and are also able to issue Intents. Services are given a higher priority by the Android runtime than many other processes and will only be terminated as a last resort by the system in order to free up resources. In the event that the runtime does need to kill a Service, however, it will be automatically restarted as soon as adequate resources once again become available. Example situations where a Service might be a practical solution include the streaming of audio that should continue when the application is no longer active, or a stock market tracking application that needs to notify the user when a share hits a specified price.

Software components - service INTENT User Interface Activity Service A service runs in background and has not a UI Used to perform a longrunning operation or to supply functionality for other applications to use. Activated explicitly, or via the intent/filter mechanism Can issue intents, notifications, or Toast message

Software components: Service System-level service WINDOW_SERVICE The top-level window manager LOCATION_SERVICE controlling location (e.g., GPS) updates CONNECTIVITY_SERVICE Handling management of network connections. User defined Intent Service (execute inside its own thread and dies) Started Service Bound Service

Notification A service, running in the background, needs a way to let users know something of interest has occurred, such as when email has been received. Moreover, the service may need some way to steer the user to an activity where they can act upon the event reading a received message, for example. For this, Android supplies status bar icons, flashing lights, and other indicators collectively known as "notifications".

Software comp content provider The content provider is the data tier for Android applications Android ships with many content providers File Stores data such as browser bookmarks Contacts Stores user contacts SQLite db Activity CONTENT PROVIDER SQLite File Remot e Data store

Content providers Content Providers implement a mechanism for the sharing of data between applications. Any application can provide other applications with access to its underlying data through the implementation of a Content Provider including the ability to add, remove and query the data (subject to permissions). Access to the data is provided via a Universal Resource Identifier (URI) defined by the Content Provider. Data can be shared in the form a file or an entire SQLite database. The native Android applications include a number of standard Content Providers allowing applications to access data such as contacts and media files. The Content Providers currently available on an Android system may be located using acontent Resolver.

Resources XML files defining: Layout (by tar the most important resource) String String array Integer array Color Styles Binary image file (icon.png) Stored in the /res/ directory Accessed from the code through a symbolic ID The mapping resource symbolic ID and resource is done through a special class, called R

Assets Accessed via an Asset Manager Files that maintain their original raw format Read the file as a stream of bytes.

Context When an application is compiled, a class named R is created that contains references to the application resources. The application manifest file and these resources combine to create what is known as the Application Context. This context, represented by the Android Context class, may be used in the application code to gain access to the application resources at runtime. In addition, a wide range of methods may be called on an application s context to gather information and make changes to the application s environment at runtime.

Demo: my first application

My first application Target API Lowest API level required from here, accept all the default options

Questions?

My first application

My first application oncreate: Called when the activity is starting. setcontentview(): inflates the layout

My first application string.xml style.xml

My first applicaition activity_main.xml

My first application @+id: creates an id called menu_settings