ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

Similar documents
ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

Android Introduction. Hello Mihail L. Sichitiu 1

MMI 2: Mobile Human- Computer Interaction Android

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

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

How to build your first Android Application in Windows

Lecture 1 Introduction to Android

Mobile Application Development

Chapter 2 Getting Started

App Development for Android. Prabhaker Matet

Hello World. by Elliot Khazon

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

Android Environment SDK

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

Android Basics. Xin Yang

Introduction to Android SDK Jordi Linares

Developing Android Apps: Part 1

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

Android Environment SDK

Android Development. Marc Mc Loughlin

Android For Java Developers. Marko Gargenta Marakana

Advantages. manage port forwarding, set breakpoints, and view thread and process information directly

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

Introduction to Android

Frameworks & Android. Programmeertechnieken, Tim Cocx

Android Architecture. Alexandra Harrison & Jake Saxton

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

Jordan Jozwiak November 13, 2011

An Introduction to Android

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

Android Development. 吳 俊 興 國 立 高 雄 大 學 資 訊 工 程 學 系

Android Mobile App Building Tutorial

Introduction to Android

Getting Started: Creating a Simple App

Tutorial #1. Android Application Development Advanced Hello World App

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

Android ( ) Frank Ducrest

Android Application Development - Exam Sample

Android Development Tutorial. Nikhil Yadav CSE40816/ Pervasive Health Fall 2011

Introduction to Android

Praktikum Entwicklung Mediensysteme (für Master)

Creating and Using Databases for Android Applications

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

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

Basics. Bruce Crawford Global Solutions Manager

How to Create an Android Application using Eclipse on Windows 7

CS378 -Mobile Computing. Android Overview and Android Development Environment

ITG Software Engineering

Development. SriSeshaa Technologies. Table of Contents

Programming with Android: SDK install and initial setup. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

06 Team Project: Android Development Crash Course; Project Introduction

IOIO for Android Beginners Guide Introduction

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

Android Programming Basics

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

An Android-based Instant Message Application

Building an Android client. Rohit Nayak Talentica Software

Smartphone market share

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

OpenCV on Android Platforms

2. Click the download button for your operating system (Windows, Mac, or Linux).

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

Android Apps Development Boot Camp. Ming Chow Lecturer, Tufts University DAC 2011 Monday, June 6, 2011

1. Introduction to Android

Tutorial for developing the Snake Game in Android: What is Android?

Building Your First App

Programming with Android: SDK install and initial setup. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Mobile Application Development Android

How to develop your own app

4. The Android System

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

Introduction to Android Programming (CS5248 Fall 2015)

Android Tutorial. Larry Walters OOSE Fall 2011

The "Eclipse Classic" version is recommended. Otherwise, a Java or RCP version of Eclipse is recommended.

Introduction to Android. CSG250 Wireless Networks Fall, 2008

Mobile Phones Operating Systems

Presenting Android Development in the CS Curriculum

DESIGNING AN M-LEARNING APPLICATION FOR A UBIQUITOUS LEARNING ENVIRONMENT IN THE ANDROID BASED MOBILE DEVICES USING WEB SERVICES

Workshop on Android and Applications Development

Admin. Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources. Recap: TinyOS. Recap: J2ME Framework

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

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

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

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

Getting Started With Android

Android Operating System

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

Hacking your Droid ADITYA GUPTA

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

Advertiser Campaign SDK Your How-to Guide

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

Location-Based Services Design and Implementation Using Android Platforms

Transcription:

Why Android? ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android Dr Dimitris C. Dracopoulos A truly open, free development platform based on Linux and open source A component-based architecture Tons of built-in services out of the box (GPS, SQL, browser and map views) Automatic management of the application life cycle High-quality graphics and sound 3D-accelerated OpenGL graphics various codecs for audio and video formats built-in Portability across a wide range of current and future hardware (apps in Java) 2 / 28 Architecture 3 / 28 1 2

Native Libraries Surface Manager: drawing commands go into off-screen bitmaps that are then combined with other bitmaps to form the display the user sees. 2D and 3D graphics: Two- and three-dimensional elements can be combined in a single user interface with Android. The library will use 3D hardware if the device has it or a fast software renderer if it doesn t. Media codecs: Android can play video and record and play back audio in a variety of formats including AAC, AVC (H.264), H.263, MP3, and MPEG-4. SQL database: Android includes the lightweight SQLite database engine, the same database used in Firefox and the Apple iphone. Browser engine: For the fast display of HTML content, Android uses the WebKit library. Same engine used in the Google Chrome browser, Apple s Safari browser, the Apple iphone, and Nokia s S60 platform. 4 / 28 Application Framework Provides the high-level building blocks you will use to create your applications. Activity Manager Controls the life cycle of applications Maintains a common backstack for user navigation Content providers: Objects encapsulate data that needs to be shared between applications (e.g. contacts) Resource manager: Resources are anything that goes with your program that is not code Location manager: An Android phone always knows where it is Notification manager: Events such as arriving messages, appointments, proximity alerts, alien invasions, and more can be presented to the user 6 / 28 Android Runtime Core Java Libraries (different than Java SE but there is a substantial amount of overlap) Dalvik: Java virtual machine optimized for low memory requirements runs.dex files, which are converted at compile time from standard.class and.jar files..dex files are more compact and efficient than class files, an important consideration for the limited memory and battery-powered devices that Android targets. 5 / 28 Applications and Widgets End users will see only these programs. Applications: Programs that can take over the whole screen and interact with the user Widgets: Operate only in a small rectangle of the Home screen application Android phones preprepackaged with a number of standard system applications, including: Phone dialer Email Contacts Web browser Android Market 7 / 28 3 4

It s Alive! Standard Linux or Windows desktop, you can have many applications running and visible at once in different windows. One of the windows has keyboard focus, but otherwise all the programs are equal. Android doesnt work that way: There is one foreground application, which typically takes over the whole display except for the status line. When the user turns on their phone, the first application they see is the Home application. When the user runs an application, Android starts it and brings it to the foreground. From that application, the user might invoke another application, or another screen in the same application, and then another and another. All these programs and screens are recorded on the application stack by the system s Activity Manager. At any time, the user can press the Back button to return to the previous screen on the stack. Building Blocks of an Application Activities: A user interface screen. Applications can define one or more activities to handle different phases of the program.each activity is responsible for saving its own state so that it can be restored later as part of the application life cycle. Intents: A mechanism for describing a specific action, such as pick a photo, or phone home. Example: there is an intent for send an email.if youre writing a new email application, you can register an activity to handle that intent and replace the standard mail program.the next time somebody tries to send an email, theyll get the option to use your program instead of the standard one. 10 / 28 8 / 28 Building Blocks of an Application (cont d) Process!= Application Each user interface screen is represented by an Activity class. Each activity has its own life cycle. An application is one or more activities plus a Linux process to contain them. In Android, an application can be alive even if its process has been killed (the activity life cycle is not tied to the process life cycle). Processes are just disposable containers for activities. 9 / 28 Services: A task that runs in the background without the users direct interaction, similar to a Unix daemon. Example: a music player. The music may be started by an activity, but you want it to keep playing even when the user has moved on to a different program. Content Providers: a set of data wrapped up in a custom API to read and write it. This is the best way to share global data between applications. Example: Google provides a content provider for contacts. All the information there - names, addresses, phone numbers, and so forth, can be shared by any application that wants to use it. 11 / 28 5 6

Using Resources A resource is a localized text string, bitmap, or other small piece of noncode information that your program needs. At build time all your resources get compiled into your application. You create and store your resources in the res directory inside your project. The Android resource compiler (aapt) processes resources according to which subfolder they are in and the format of the file. For example: PNG and JPG format bitmaps should go in a directory starting with res/drawable XML files that describe screen layouts should go in a directory starting with res/layout 12 / 28 Safety and Security (cont d) Some of the most common permissions are: INTERNET: Access the Internet. READ CONTACTS: Read (but dont write) the user s contacts data. WRITE CONTACTS: Write (but dont read) the user s contacts data. RECEIVE SMS: Monitor incoming SMS (text) messages. ACCESS COARSE LOCATION: Use a coarse location provider such as cell towers or wifi. ACCESS FINE LOCATION: Use a more accurate location provider such as GPS. For example, to monitor incoming SMS messages, you would specify this in the manifest file: 14 / 28 Safety and Security Every application runs in its own Linux process. The hardware forbids one process from accessing another process s memory. Every application is assigned a specific user ID. Any files it creates cannot be read or written by other applications. In addition: Access to certain critical operations are restricted, and you must specifically ask for permission to use them in a file named Android-Manifest.xml. When the application is installed, the Package Manager either grants or doesn t grant the permissions based on certificates and, if necessary, user prompts. 13 / 28 Safety and Security (cont d) <manifest xmlns:android="http://schemas.android.com/ apk/res/android" package="com.google.android.app.myapp" > <uses-permission android:name= "android.permission.receive_sms" /> </manifest> 15 / 28 7 8

Installing the Android Software There are 5 different components to install (assuming you use Eclipse): Java JDK Eclipse (version Eclipse IDE for Java Developers) SDK Starter Package Adding Platforms and Other Components To do so run the android utility found in the tools directory of the Android SDK started package (see previous step) ADT Plugin for Eclipse Full instructions for all the above are given in: http://d.android.com/sdk/installing.html 16 / 28 Create a New Android Project 1. From Eclipse, select File New Project. 2. Select Android Project and click Next. 3. Fill in the project details with the following values: Project name: HelloAndroid Application name: Hello, Android Package name: com.example.helloandroid (or your own private namespace) Create Activity: HelloAndroid 4. Click Finish. 18 / 28 Create an AVD Before running an application in the Android emulator you need to create an Android Virtual Device (AVD). To create an AVD: 1. In Eclipse, choose Window Android SDK and AVD Manager. 2. Select Virtual Devices in the left panel. 3. Click New. The Create New AVD dialog appears. 4. Type the name of the AVD, such as my avd. 5. Choose a target. The target is the platform (that is, the version of the Android SDK, such as 2.3) you want to run on the emulator. You can ignore the rest of the fields for now. 6. Click Create AVD. 17 / 28 Writing a Hello Android After the project is created, Eclipse generates the following Java code found in file HelloAndroid.java (name of the activity). Open that with the Package Explorer. The file is located under HelloAndroid src com.example.helloandroid). package com.example.helloandroid; import android.app.activity; import android.os.bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); 19 / 28 9 10

Writing a Hello Android (cont d) Modify the code to look like the following: Running the Hello Android Program Select Run Run. package com.example.helloandroid; import android.app.activity; import android.os.bundle; import android.widget.textview; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); TextView tv = new TextView(this); tv.settext("hello, Android"); setcontentview(tv); 20 / 28 The Android Emulator Home Page 22 / 28 Programmatic vs Declarative Design Android offers two ways to create use interface design: Programmatic: using Java classes Declarative: using XML-based layout files. 23 / 28 21 / 28 11 12

Declarative Approach for the Hello World Program Open the main.xml file under the res layout directory: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/ apk/res/android" android:id="@+id/textview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello"/> 24 / 28 Declarative Approach for the Hello World Program (cont d) Now modify the HelloAndroid.java class to look like the following will display the string Hello, Android! I am a string resource!: package com.example.helloandroid; import android.app.activity; import android.os.bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); 26 / 28 Declarative Approach for the Hello World Program (cont d) Modify the file res/values/strings.xml to look like the following: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">hello, Android! I am a string resource!</string> <string name="app_name">hello, Android</string> </resources> 25 / 28 The R Class File R.java is autogenerated and contains an index into all the resources defined in the file. You use this class in your source code as a sort of short-hand way to refer to resources you ve included in your project. You should never edit this file by hand. 27 / 28 13 14

The R Class (cont d) package com.example.helloandroid; public final class R { public static final class attr { public static final class drawable { public static final int icon=0x7f020000; public static final class id { public static final int textview=0x7f050000; public static final class layout { public static final int main=0x7f030000; public static final class string { public static final int app_name=0x7f040001; public static final int hello=0x7f040000; 28 / 28 15