Android Framework. How to use and extend it

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

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

As shown, the emulator instance connected to adb on port 5555 is the same as the instance whose console listens on port 5554.

Running a Program on an AVD

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

Android Geek Night. Application framework

Lab 4 In class Hands-on Android Debugging Tutorial

Android Programming and Security

Chapter 2 Getting Started

Introduction to Android. CSG250 Wireless Networks Fall, 2008

Open Source Telemedicine Android Client Development Introduction

ADT Plugin for Eclipse

Android Development. Marc Mc Loughlin

Introduction to Android Development. Jeff Avery CS349, Mar 2013

Android Tutorial. Larry Walters OOSE Fall 2011

1. Introduction to Android

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

Android Environment Emulator

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

Android Application Development - Exam Sample

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

Android Environment SDK

Android Environment SDK

Android Application Development Lecture Notes INDEX

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)

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

Getting started with Android and App Engine

BEGIN ANDROID JOURNEY IN HOURS

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

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

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

How To Develop Android On Your Computer Or Tablet Or Phone

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

ID TECH UniMag Android SDK User Manual

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

OpenCV on Android Platforms

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

Android Developer Fundamental 1

Developing for MSI Android Devices

ADB (Android Debug Bridge): How it works?

Android Programming. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

An Introduction to Android

Android, Bluetooth and MIAC

Tutorial #1. Android Application Development Advanced Hello World App

4. The Android System

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

Qualcomm IR-I 2 C Bridge Demo

Android Systems Programming Tips and Tricks

CHAPTER 1: INTRODUCTION TO ANDROID, MOBILE DEVICES, AND THE MARKETPLACE

Developing Android Apps: Part 1

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

Android Basics. Xin Yang

Mobile Application Security and Penetration Testing Syllabus

Introduction to Android Android Architecture Software Development Purpose of the project Location Based Service (LBS) Android. Location class Google

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

Smartphone market share

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

Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

Android Framework. How to use and extend it

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

Mobile Application Development

Android Development Exercises Version Hands On Exercises for. Android Development. v

Introduction to Android

Getting Started with Android Development

Jordan Jozwiak November 13, 2011

Mobile Application Development 2014

Mobile Application Development Android

How to Create an Android Application using Eclipse on Windows 7

Android For Java Developers. Marko Gargenta Marakana

UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

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

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

Getting Started: Creating a Simple App

Penetration Testing Android Applications

Android Mobile App Building Tutorial

How To Develop An Android App On An Android Device

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

Introduction to Android

Developing NFC Applications on the Android Platform. The Definitive Resource

Developing In Eclipse, with ADT

MMI 2: Mobile Human- Computer Interaction Android

XenMobile Logs Collection Guide

Pentesting Android Apps. Sneha Rajguru

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

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

INFORMATION BROCHURE

Develop a Hello World project in Android Studio Capture, process, store, and display an image. Other sensors on Android phones

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

Android Development Setup [Revision Date: 02/16/11]

Android Application Repackaging

The power of root on Android emulators

Example Connection between USB Host and Android

Tutorial on Basic Android Setup

AndroLIFT: A Tool for Android Application Life Cycles

CS378 -Mobile Computing. Android Overview and Android Development Environment

Transcription:

Android Framework How to use and extend it

Lecture 3: UI and Resources Android UI Resources = {XML, Raw data} Strings, Drawables, Layouts, Sound files.. UI definition: Layout example Elements of advanced UI Use Android prebuilt resources How to enhance application Portability: Localization Different screen size/ratio/orientation Alberto Panizzo 2

Lab 2: Developer's tools SDK related: android, emulator THE developer's tool adb Debugging: logcat, ddms, traceview Graphical: draw9patch, hierarchyviewer, layoutopt [1] Alberto Panizzo 3

android If you have already installed the Android SDK, you are also familiar with the android graphical tool: Manage installed packages, components of the Android SDK Manage Android Virtual Devices The shell command allow you also to manage Android Projects: $ android create project -n <name> -t <targetid> -k <package_name> \ -a <default_activity_name> -p <root_path> $ android list targets $ android update project [-n <name>] -p <root_path> \ [-l <library_path>] [-t <targetid>] Alberto Panizzo 4

emulator Execute an Android Virtual Device inside qemu The only reqired parameter is: -avd <name> Few interesting options: What is happening? -show-kernel display kernel messages -shell enable root shell on current terminal -prop <name>=<value> set system property on boot Peripheral connection: -radio <device> redirect radio modem interface to char device -gps <device> redirect NMEA GPS to character device Execute custom images: -sysdir <dir> search for system disk images in <dir> -system <file> read initial system image from <file> -datadir <dir> write user data into <dir> -kernel <file> use specific emulated kernel -ramdisk <file> ramdisk image (default <system>/ramdisk.img) Alberto Panizzo 5

Lab 2: Developer's tools SDK related: android, emulator THE developer's tool adb Debugging: logcat, ddms, traceview Graphical: draw9patch, hierarchyviewer, layoutopt Alberto Panizzo 6

adb Android Debug Bridge implements a custom protocol to communicate with the device (emulator/real device) and achieve several functionalities $ adb [-d -e -s <serialnumber>] <command> List devices -e -d $ adb devices List of devices attached emulator-5554 device 343256F8A32400EC device -s Adb is acting wired? $ adb kill-server $ adb devices Alberto Panizzo 7

adb File management: $ adb push <local> <remote> $ adb pull <remote> [<local>] Package management: $ adb install [-r] [-s] <file> # -r reinstall -s on sd-card $ adb uninstall [-k] <package_name> # -k keep data Run an interactive shell or execute a command: $ adb shell [command] Shortcut to logcat: $ adb logcat Connect a device via TCP/IP: $ adb connect [host[:port]] # If no host is specified it take # $ADBHOST otherwise localhost Alberto Panizzo 8

Lab 2: Developer's tools SDK related: android, emulator THE developer's tool adb Debugging: logcat, ddms, traceview Graphical: draw9patch, hierarchyviewer, layoutopt Data: sqlite3 Alberto Panizzo 9

Logging Java interface to write into the system log buffer: import android.util.log; public class AnActivity extends Activity { Private static String TAG = "MyTag"; } public void f() { Log.e(TAG, "Error"); Log.w(TAG, "Warning"); Log.i(TAG, "Info"); Log.d(TAG, "Debug"); Log.v(TAG, "VerboseDebug"); } [2] Alberto Panizzo 10

logcat Tool running on the device which shows the system logs $ adb shell logcat [options] [filterspecs] $ adb logcat [options] [filterspecs] Results: $ adb logcat I/DEBUG ( 31): debuggerd: Jun 30 2010 13:59:20 D/qemud ( 38): entering main loop I/Vold ( 29): Vold 2.1 (the revenge) firing up I/Netd ( 30): Netd 1.0 starting W/Vold ( 29): No UMS switch available D/qemud ( 38): fdhandler_accept_event: accepting on fd 10 D/qemud ( 38): created client 0xe078 listening on fd 8 D/qemud ( 38): client_fd_receive: attempting registration for service 'boot-properties' D/qemud ( 38): client_fd_receive: -> received channel id 1 D/qemud ( 38): client_registration: registration succeeded for client 1... Alberto Panizzo 11

logcat Results: <level>/<tag> (<pid>): Message level: E/W/I/D/V (Error/Warning/Info/Debug/Verbose) tag: Component specific log tag pid: Process ID hosting the component message: Log message Useful options: -c Clear the log cache -d Dump the log cache and exit -b Select the buffer: 'main'(def), 'events', 'radio' You can use filterspecs or egrep: $ adb logcat egrep -w 'AudioFlinger AudioHardware ALSALib' Alberto Panizzo 12

ddms Alberto Panizzo 13

ddms Key features: Embeds logcat output (colored/full functional) Device Screenshots/File manager Device Screen capture.. Easy interface to dump system info Device Dump* On-demand start/stop profiling on certain processes Embeds in Eclipse through the ADT plugin Alberto Panizzo 14

traceview [3] Alberto Panizzo 15

Lab 2: Developer's tools SDK related: android, emulator THE developer's tool adb Debugging: logcat, ddms, traceview Graphical: draw9patch, hierarchyviewer, layoutopt Alberto Panizzo 16

draw9patch Achieve a Nine-patch stretchable image from a.png file Alberto Panizzo 17

hierarchyviewer Analyse the layout hierarchy of the current activity running on the emulator (eng or userdebug build) [4] Alberto Panizzo 18

hierarchyviewer Alberto Panizzo 19

layoutopt Report a number of common bad behaviors in defining layouts $ layoutopt samples/ samples/compound.xml 7:23 The root-level <FrameLayout/> can be replaced with <merge/> 11:21 This LinearLayout layout or its FrameLayout parent is useless samples/simple.xml 7:7 The root-level <FrameLayout/> can be replaced with <merge/> samples/too_deep.xml -1:-1 This layout has too many nested layouts: 13 levels, it should have <= 10! 20:81 This LinearLayout layout or its LinearLayout parent is useless 24:79 This LinearLayout layout or its LinearLayout parent is useless 28:77 This LinearLayout layout or its LinearLayout parent is useless 32:75 This LinearLayout layout or its LinearLayout parent is useless 36:73 This LinearLayout layout or its LinearLayout parent is useless samples/too_many.xml 7:413 The root-level <FrameLayout/> can be replaced with <merge/> -1:-1 This layout has too many views: 81 views, it should have <= 80! samples/useless.xml 7:19 The root-level <FrameLayout/> can be replaced with <merge/> 11:17 This LinearLayout layout or its FrameLayout parent is useless Alberto Panizzo 20

Notes on past exercise Clean the code Remove all useless things Do not show me that you copied some examples.. Coding style Indent with spaces or tabs? Be consistent Comment the code to make me understand that you have understood Localize as much as possible (at least all XML) Be sure it's working Otherwise ask me Alberto Panizzo 21

Notes on past exercise The solution was to create a BroadcastReceiver and register it (within the AndroidManifest.xml) to receive the action: android.intent.action.boot_completed Because this action is sent as broadcast. Within the onreceive() the chosen Activity will be started using startactivity() with the correct intent. The application must acquire the following permission: android.permission.receive_boot_completed to be able to receive the boot completed action Alberto Panizzo 22

Exercise Develop an Android application which match the shown layout. This application must be able to switch the picture shown among all the available pictures set using the arrows. Download all the resources needed from the course website: http://retis.sssup.it/~panizzo/android/material/lect4-res.tgz Alberto Panizzo 23

Links of interest [1] http://developer.android.com/guide/developing/tools/index.html [2] http://developer.android.com/guide/developing/debugging/debugging-log.html [3] http://developer.android.com/guide/developing/debugging/debugging-tracing.html [4] http://developer.android.com/guide/developing/debugging/debugging-ui.html Alberto Panizzo 24