App Development for Android. Prabhaker Matet



Similar documents
Android Introduction. Hello Mihail L. Sichitiu 1

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

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

Android For Java Developers. Marko Gargenta Marakana

Mobile Application Development

MMI 2: Mobile Human- Computer Interaction Android

Developing Android Apps: Part 1

Chapter 2 Getting Started

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

Android Development. Marc Mc Loughlin

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

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

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

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

Lecture 1 Introduction to Android

Hello World. by Elliot Khazon

Tutorial #1. Android Application Development Advanced Hello World App

Hacking your Droid ADITYA GUPTA

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

Android Application Development - Exam Sample

SDK Quick Start Guide

Jordan Jozwiak November 13, 2011

Introduction to Android Programming (CS5248 Fall 2015)

How to build your first Android Application in Windows

Smartphone market share

4. The Android System

Building an Android client. Rohit Nayak Talentica Software

Android Geek Night. Application framework

Android Environment SDK

06 Team Project: Android Development Crash Course; Project Introduction

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

Android Environment SDK

Programming with Android

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

Android Programming Basics

Location-Based Services Design and Implementation Using Android Platforms

An Introduction to Android

Frameworks & Android. Programmeertechnieken, Tim Cocx

Android Fundamentals 1

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

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

Lab 4 In class Hands-on Android Debugging Tutorial

Introduction to Android. CSG250 Wireless Networks Fall, 2008

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

Getting started with Android and App Engine

ITG Software Engineering

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

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

Basics. Bruce Crawford Global Solutions Manager

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

Android Mobile App Building Tutorial

Introduction to Android

Building Your First App

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

Introduction to Android SDK Jordi Linares

Running a Program on an AVD

Getting Started: Creating a Simple App

Android Services. Services

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

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

Overview of CS 282 & Android

The power of root on Android emulators

Android Basics. Xin Yang

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

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)

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

A software stack for mobile devices:

Mocean Android SDK Developer Guide

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

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

Introduction to Android

BEGIN ANDROID JOURNEY IN HOURS

Android Java Live and In Action

1. Introduction to Android

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

IOIO for Android Beginners Guide Introduction

Presenting Android Development in the CS Curriculum

ANDROID TUTORIAL. Simply Easy Learning by tutorialspoint.com. tutorialspoint.com

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

Mobile Application Development Android

Android Development Tutorial. Human-Computer Interaction II (COMP 4020) Winter 2013

Android Tutorial. Larry Walters OOSE Fall 2011

CSE476 Mobile Application Development. Yard. Doç. Dr. Tacha Serif Department of Computer Engineering Yeditepe University

Android Programming: Installation, Setup, and Getting Started

Homeschool Programming, Inc.

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

Android Concepts and Programming TUTORIAL 1

Login with Amazon Getting Started Guide for Android. Version 2.0

Localization and Resources

ANDROID BASED MOBILE APPLICATION DEVELOPMENT and its SECURITY

An Android-based Instant Message Application

Transcription:

App Development for Android Prabhaker Matet

Development Tools (Android) Java Java is the same. But, not all libs are included. Unused: Swing, AWT, SWT, lcdui Eclipse www.eclipse.org/ ADT Plugin for Eclipse developer.android.com/ Android SDK developer.android.com/ Android Device Emulator Development Platforms: Linux, Mac OSX, or Windows 2

(Other) Languages and IDEs IntelliJ Idea Android Studio Corona for Android Android Natve Development Kit (NDK) Scala 3

Applicaton Runtme Each applicaton is a different user. Each applicaton gets a unique Linux user ID. The system sets permissions for all the files in an applicaton so that only the user ID assigned to that applicaton can access them. Each process has its own Dalvik/Art VM. Every applicaton runs in its own Linux process. A process can have multple threads. 4

Applicaton Framework Views lists, grids, text boxes, butons, embeddable web browser Content Providers to access data from other applicatons, or to share their own data Resource Manager access non-code resources; e.g., strings, graphics, and layout files Notficaton Manager alerts in the status bar Actvity Manager lifecycle of applicatons and navigaton backstack 5

Applicaton Components Activity: (GUI) functons that the applicaton performs. Service: no UI run in the background; Long-running; for remote processes no user interface. Content Providers facilitate data transmission among different applicatons. Broadcast Receiver: respond to announcements. Groups of views define the applicaton s layout. Each component is a different entry point of the system. An applicaton can have multple instances of the above. 6

Actvity An applicaton typically consists of several screens: Each screen is implemented by one actvity. Moving to the next screen means startng a new actvity. An actvity may return a result to the previous actvity. 7

Actvity One of the actvites is marked as the main one. Presented on launch. An actvity is usually a single screen: Implemented as a single class extending Actvity. Displays user interface controls (views). Reacts on user input/events. 8

Life cycle of an Actvity 9

Services A service does not have a (visual) user interface. Runs in the background for an indefinite period tme. Examples: music player, network download, Similar to daemons in Linux/Unix or Windows services. Each service extends the Service base class. Communicate with the service through an interface defined in AIDL (Android Interface Definiton Language). 10

Services Interprocess communicaton (IPC). startservice(); stopself() ; stopservice() bindservice(). Multple components can bind to the service at once. When all of them unbind, the service is destroyed. onstartcommand() onbind() oncreate() ondestroy() 11

Broadcast Receivers Broadcast announcements: Intents. All receivers extend the BroadcastReceiver base class. Many broadcasts originate in the System. Ex: the tme zone has changed Ex: the batery is low Applicatons can also initate broadcasts. 12

Content Providers Enables sharing of content across applicatons E.g., address book, photo gallery the only way to share data between applicatons. APIs for query, delete, update and insert. Use ContentResolver methods to do the above. Content is represented by URI and MIME type. 13

Content Providers Application Application Activity Activity Application Activity Content Resolver Service Content Resolver Content Provider Content Resolver Data SQLite XML Remote Store 14

Intent Examples ACTION_DIAL content://contacts/people/13 Display the phone dialer with the person #13 filled in. ACTION_VIEW content://contacts/people/ Display a list of people, which the user can browse through. startactvity(new Intent(Intent.VIEW_ACTION, Uri.parse( "htp://www.fhnw.ch")); startactvity(new Intent(Intent.VIEW_ACTION, Uri.parse("geo:47.480843,8.211293")); startactvity(new Intent(Intent.EDIT_ACTION, Uri.parse("content://contacts/people/1")); atributes: category, type, component, extras 15

Intent Intents are system messages: Actvity events ( launch app, press buton) Hardware state changes (acceleraton change, screen off, etc) Incoming data (Receiving call, SMS arrived) An intent object is an acton to be performed on some data URI. Provides binding between applicatons. 16

public class Intent startactvity to launch an actvity. broadcastintent to send it to a BroadcastReceiver Communicate with a Service startservice(intent) or bindservice(intent, ServiceConnecton, int) Explicit Intents specify a component to be run. setcomponent(componentname) or setclass(context, Class)) Implicit Intents match an intent against all of the <intent-filter>s in the installed applicatons. 17

IntentReceivers Components that respond to Intents Way to respond to external notficaton or alarms Apps can create and broadcast own Intents 18

Example App: Hello World! developer.android.com/resources/tutorials /hello-world.html

The Emulator QEMU-based ARM emulator Displays the same image as the device Limitatons: Camera GPS 20

Goal Create a very simple applicaton Run it on the emulator Examine its structure 21

Building HelloAndroid Create a Project htp://developer.android.com/training/basics/first app/creatng-project.html Generates several files Next few slides Modify HelloAndroid.java as needed Android-Develop-1 22

helloandroid Manifest 1. <?xml version="1.0" encoding="utf-8"?> 2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3. package="com.example.helloandroid" 4. android:versioncode="1" 5. android:versionname="1.0"> 6. <applicaton android:icon="@drawable/icon" android:label="@string/app_name"> 7. <actvity android:name=".helloandroid" 8. android:label="@string/app_name"> 9. <intent-filter> 10. <acton android:name="android.intent.action.main" /> 11. <category android:name="android.intent.category.launcher" /> 12. </intent-filter> 13. </actvity> 14. </applicaton> 15. </manifest> 23

HelloAndroid.java package com.example.helloandroid; import android.app.actvity; import android.os.bundle; public class HelloAndroid extends Actvity { /** Called when the actvity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } } Set the layout of the view as described in the main.xml layout 24

HelloAndroid.java package com.example.helloandroid; import android.app.actvity; import android.os.bundle; import android.widget.textview; Inherit from the Activity Class public class HelloAndroid extends Actvity { /** Called when the actvity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); TextView tv = new TextView(this); tv.settext("hello, Android by hand"); setcontentview(tv); } } Set the view by hand from the program 25

Run it! 26

Android Applicaton Package: APK res/layout: declaraton layout files res/drawable: intended for drawing res/anim: bitmaps, animatons for transitons res/values: externalized values strings, colors, styles, etc res/xml: general XML files used at runtme res/raw: binary files (e.g., sound) An applicaton consists of: Java Code Data Files Resources Files 27

APK Content All source code here Java code for our activity All non-code resources Images Generated Java code Helps link resources to Java code Layout of the activity Strings used in the program Android Manifest 28

Android Applicaton Package: APK Using Java/Eclipse/ADT develop source files. An Android applicaton is bundled by the aapt tool into an Android package (.apk) An.apk file is a zip file. Invoke unzip if you wish. Installing an Applicaton is a built-in op of Android OS. 29

.apk Internals 1. AndroidManifest.xml deployment descriptor for applicatons. 2. IntentReceiver as advertsed by the IntentFilter tag. 3. *.java files implement Android actvity 4. Main.xml visual elements, or resources, for use by actvites. 5. R.java automatcally generated by Android Developer Tools and "connects" the visual resources to the Java source code. 6. Components share a Linux process: by default, one process per.apk file. 7..apk files are isolated and communicate with each other via Intents or AIDL. 30

Applicaton Resources anything relatng to the visual presentaton of the applicaton images, animatons, menus, styles, colors, audio files, resource ID alternate resources for different device configuratons 31

AndroidManifest.xml Declares all applicaton components: <actvity> <service> <provider> for content providers <receiver> for broadcast receivers The manifest can also: Identfy any user permissions the applicaton requires, such as Internet access or read-access to the user's contacts. Declare hardware and software features used or required by the applicaton API libraries the applicaton needs 32

/res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientaton="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout> Further redirection to /res/values/strings.xml 33

/res/values/strings.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">hello World, HelloAndroid by resources!</string> <string name="app_name">hello, Android</string> </resources> 34

/gen/r.java package com.example.helloandroid; public final class R { public statc final class atr { } public statc final class drawable { public statc final int icon=0x7f020000; } public statc final class id { public statc final int textview=0x7f050000; } public statc final class layout { public statc final int main=0x7f030000; } public statc final class string { public statc final int app_name=0x7f040001; public statc final int hello=0x7f040000; } } R.java is auto generated on build. Based on the resource files (including layouts and preferences) Do not edit. 35

Run it! 36

Debugging adb Android Debug Bridge moving and syncing files to the emulator running a Linux shell on the device or emulator Dalvik Debug Monitor Server DDMS is GUI + adb. capture screenshots gather thread and stack informaton spoof incoming calls and SMS messages Device or Android Virtual Device JDWP Java Debug Wire Protocol Java IDEs include a JDWP debugger command line debuggers such as jdb. 37

Introduce A Bug package com.example.helloandroid; import android.app.actvity; import android.os.bundle; public class HelloAndroid extends Actvity { /** Called when the actvity is first created. */ @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); Object o = null; o.tostring(); setcontentview(r.layout.main); } } 38

Run it! 39

Source Code for Android Examples Sources for many Android applicatons that can be enhanced: htp://code.google.com htp://developer.android.com/resources/brow ser.html?tag=sample 40