+ All Categories
Home > Documents > To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software...

To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software...

Date post: 05-Jun-2020
Category:
Upload: others
View: 11 times
Download: 0 times
Share this document with a friend
31
Introduction An Android application Debugging tools Haptimap Toolkit Introduction DEMO To program Android Activities, Services, Intents and DDMS Miguel Molina Certec, Division of Rehabilitation Engineering Research Department of Design Sciences Faculty of Engineering Lund University 2011-10-27 Miguel Molina To program Android
Transcript
Page 1: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

To program AndroidActivities, Services, Intents and DDMS

Miguel Molina

Certec, Division of Rehabilitation Engineering ResearchDepartment of Design Sciences

Faculty of EngineeringLund University

2011-10-27

Miguel Molina To program Android

Page 2: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Outline

1 IntroductionAndroid OSAndroid SDK

2 An Android applicationActivities, Services and IntentsThe Lifecycle of Activities and Services

3 Debugging toolsDDMS

4 Haptimap Toolkit IntroductionThe HaptiMap ToolkitSome Android HCI Modules

5 DEMO

Miguel Molina To program Android

Page 3: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Android OSAndroid SDK

What is Android

What is Android? Really?

An Open Platform for Mobile DevelopmentIt is NOT a mobile phoneA package of preinstalled applicationsA software development kit used to create applicationsBuilds on a Linux Kernel. Not a Linux OSA full set of std Linux utilities not included

Miguel Molina To program Android

Page 4: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Android OSAndroid SDK

Why Android?

Open SourceFree mobile OSYou might develop from different platforms (Windows,Linux, Mac)You are already familiar with JavaExpected to account for 49% of the smartphone market by2012 (according to Gartner)

Miguel Molina To program Android

Page 5: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Android OSAndroid SDK

System-Architecture

How does it look like?

Miguel Molina To program Android

Page 6: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Android OSAndroid SDK

The Android Software Stack

Linux Kernel Provides the abstraction layer betweenhardware and the above layersNative Libraries C/C++ build function libraries and nativeservers. Hardware Abstraction Libraries: GPS, Audio,Camera...Android Run Time Makes the phone to an Android andnot a mobile Linux implementation

Dalvik Virtual Machine is Android’s virtual machine thatruns optimized Dalvik bytecodeSupports multiple virtual machine processes per device

Miguel Molina To program Android

Page 7: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Android OSAndroid SDK

Core Libraries: Core API for Java LanguageFamiliar development platform: Data structures, Utilities,File access, etc..

Application Framework Provides the classes used tocreate Android applications. Hardware services areaccessed through local Manager objects:LocationManager mLocationManager =(LocationManager)getSystemService(LOCATION_SERVICE);

Application Layer All applications (native and 3rd party)are build on this layer

Miguel Molina To program Android

Page 8: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Android OSAndroid SDK

Advantages using the Linux Kernel

Each Android application runs in its own virtual machineSome core functions the kernel handles

Low-level memory managementPower Management with more aggressive policyApplication permissions and security modelWi-Fi, audio, Flash memory, camera, displayProcesses management and threading

Miguel Molina To program Android

Page 9: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Android OSAndroid SDK

Android SDK Features

Some of the features available on the Android SDKAPIs for location-based services, such as GPSMultimedia hardware control such as playback, recording,camera, etc.APIs for sensors, such as accelerometer and compassIntegration of Map controls: Google MapsSupport for 2D and 3D graphics using OpenGLSQLite Database

Miguel Molina To program Android

Page 10: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

What is an Android Application?An Android application is a collection of one or more tasks(activities or services) plus a Linux process to containthem

Miguel Molina To program Android

Page 11: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

Multiple Applications

Android allows multiple applications to run concurrentlyApplications can be interrupted and paused when eventsoccurThere can be only one active application visible to the userat a time.

Miguel Molina To program Android

Page 12: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

Activity vs Service

Activity Visible screen in the applicationService An activity without a user interface

Miguel Molina To program Android

Page 13: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

What is an Activity?

A task or purposeA user interface screenIt has its own life cycleThey extend the Context class(you can get global info about your application)

Miguel Molina To program Android

Page 14: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

The Lifecycle of an Activity

Miguel Molina To program Android

Page 15: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

An activity’s lifecycle: Some @Override methodsonCreate() Creates the layout, data binding, contentviewonResume() An appropriated place to retrieve neededinstances to resources. Ex starting audio, video,animationsonPause() Ex: stop audio, video or animations started atonResume(). Could be the last thing to run before theapplication is killed. A new foreground Activity will not startuntil the onPause() returns.onStop() and onDestroy() might not be executed at all.

Miguel Molina To program Android

Page 16: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

Service

What is a Service?

A task that works in the background(similar to a daemon)It runs on the same process as the application it is part of.It is not a ThreadNo user direct interactionClients may bind to service(Preferable than a Singleton pattern)

Miguel Molina To program Android

Page 17: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

Miguel Molina To program Android

Page 18: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

A service’s lifecycle methods: Fewer than activity’sonCreate(): initial setuponStart(Intent intent): Start the active lifetime of aservice.onDestroy(): releases all resources

Miguel Molina To program Android

Page 19: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

IntentsThe Message Mechanism

Intents?

An asynchronous message system that can be used topass data between activities.Describes a specific actionWhat’s your intention?Send mail, Open the browser, Start the camera, etc...

Miguel Molina To program Android

Page 20: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

Intents Examples

Two examples when starting activitieswith different purposes:

startActivity(new Intent(...));startActivityForResult(new Intent(...));

Passing additional info to the intent

Intent intent = new Intent(...)intent.putExtra("someString", "info")

someString follows the convention:someString ="se.lth.certec.somestring"

Miguel Molina To program Android

Page 21: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

Activities, Services and IntentsThe Lifecycle of Activities and Services

Exchange Data between Activities

Use Intents:intent.putExtra("someString", myClass);

You can send objects if they are Parcelable:MyClass implements Parcelable {...}The other activity:getIntent().getParcelableExtra("someString");Implement the Serializable MyClass implementsSerializable {...}Use SharedPreferencesORUse a service as a Singleton pattern

Miguel Molina To program Android

Page 22: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

DDMS

Debugging

The Dalvik Debug Monitor Service (DDMS) can be started fromEclipse or from the the cmd/shell -> /Android directory/ddms.bat

Miguel Molina To program Android

Page 23: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

DDMS

System.out.print / Log.*

Log messages on DDMSLog.e(..., ...) ErrorsLog.w(..., ...) WarningsLog.i(..., ...) InformationLog.d(..., ...) DebuggingLog.v(..., ...) VerboseLog.wtf(..., ...) What a Terrible Failure (Since 2.2)

Miguel Molina To program Android

Page 24: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

The HaptiMap ToolkitSome Android HCI Modules

What is HaptiMap Toolkit

It offers FIVE unique features and advantages

Access to Geographic Data in Vector formatInfrastructure for Acquiring Geographic Data from MultipleSourcesDynamic Contextualised Map RenderingCross platform API for mobile and desktop platformsPluggable HCI modules for specific platforms

Miguel Molina To program Android

Page 25: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

The HaptiMap ToolkitSome Android HCI Modules

Toolkit Architecture

Miguel Molina To program Android

Page 26: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

The HaptiMap ToolkitSome Android HCI Modules

Haptic Guide HCI

Miguel Molina To program Android

Page 27: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

The HaptiMap ToolkitSome Android HCI Modules

Audio Guide HCI

Miguel Molina To program Android

Page 28: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

The HaptiMap ToolkitSome Android HCI Modules

Speech Guide HCI

Miguel Molina To program Android

Page 29: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

The HaptiMap ToolkitSome Android HCI Modules

Scan Orientation HCI

Miguel Molina To program Android

Page 30: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

The HaptiMap ToolkitSome Android HCI Modules

Sound Bubbles HCI

Miguel Molina To program Android

Page 31: To program AndroidTo program Android Activities, Services, Intents and DDMS ... A software development kit used to create applications Builds on a Linux Kernel. Not a Linux OS ...

IntroductionAn Android application

Debugging toolsHaptimap Toolkit Introduction

DEMO

DEMO

Miguel Molina To program Android


Recommended