android developer intro

Post on 10-May-2015

814 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Android Developer Introduction

Eric Faccereric.faccer@gmail.com

Tricorder

Presentation Overview

• Dream/ADP1 Handset Overview• The Android SDK• The Android Software Stack• Advanced Concepts• Web Resources

HTC Dream

• Qualcomm ARM based CPU• Camera• Accelerometer• GPS, Digital Compass• WIFI, Bluetooth• TouchScreen• 3D Graphics

Other Devices• Openmoko FreeRunner• Motorola A1200 Ming• HTC Vogue• HTC Touch• Nokia N810• Nokia 770• Asus EEEPC 701• Asus EEEPC 1000H• Always Innovating Touch Book• Dell Axim x51v

Open Handset Alliance• Mobile Phone Consortium dedicated to open

standards for mobile devices.

• Google, HTC, Intel, Samsung, Motorola, Qualcomm, T-Mobile, Sprint Nextel, Nvidia, Sony Ericsson, Vodaphone, ARM Holdings, Asustek, Toshiba, Garmin.

• Nokia has hedged their bets and reportedly has a large team working on android.

What is Android• Custom Linux Distribution and Java-based Virtual Machine

• Based on the Java language 1.5 standard

• Java is an overloaded term. It refers to:– A language with a distinct syntax/grammar– A class library– A stack based virtual machine

• Android has implemented their own VM called Dalvik. Dalvik is different because it uses a register based VM architecture.

• The practical consequence of the decision to drop the Java VM is standard java classes cannot be used on android without conversion.

What is Android

SDK Demo & Tools Overview

• Eclipse Plugin• DDMS• HierarchyViewer

• Activitycreator• Aapt Tool• Dx

Activity class• Roughly corresponds to a single “screen”

• Your application’s entry point.

• Does not require a user interface, but that would be atypical.

• When a new screen opens, the previous screen is paused and put onto a history stack. The user can then navigate backwards through previously opened screens in the history. Screens can also be removed from the history stack when it would be inappropriate for them to remain.

Service class

• Application component that runs in the background, for an indefinite period of time.

• OpenBinder – System Level IPC and Component Framework

• Local Services and Remote Services• Remote Services require using aidl and

Parcelable classes

Activity or Service Blocking

• Use Threads liberally.

• If your application or service blocks, the ActivityManager will come over and throw up a nasty ANR error for Application Not Responding.

• If you start getting these, you know what to do.

AndroidManifest.xml

• A means for publishing application metadataService Registration:<service android:name= "org.tricorder.android.TableService" />

Permissions:<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

Intent-Filters:<intent-filter>

<action android:name="org.tricorder.android.generic.service.ITrackerService"/><action android:name="org.tricorder.android.generic.service.REMOTE_SERVICE"/>

</intent-filter>

Intent class

• An intent is a description of an operation to be performed.

• It can be used with Activity.startActivity() to launch an Activity or Context.BindService() to communicate with a Service. It can be broadcast system-wide to send it to any interested BroadcastReceiver components

Intent ExampleIntent myIntent = new Intent(

android.content.Intent.ACTION_VIEW, Uri.parse("geo:38.899533,-77.036476"));

startActivity(myIntent);

Will open up the Maps Activity with the specified coordinates.

Resources• Android SDK apps have no access to the

underlying filesystem (except /sdcard)• Resources are build time artifacts (files) that are

included in your application package.

res/drawable – for images png/jpg, etc.res/layout – for xml layout filesres/menu – for xml based menu specificationsres/values – for strings, dimensions, etc.res/anim – for animations

res/raw – for raw files

BroadcastReceiver• A means to respond to system level events

• The interface consists of a single method:onReceive() { }

• To use in your Activity:• registerReceiver() in your Activity’s onResume() callback• unRegisterReceiver() in your Activity’s onPause() method

• You can’t use it as an arbitrary message bus, because it will miss messages when the it’s Activity is inactive.

• This holds even if you fail to unregister the receiver. Unregistering the receiver is merely good practice that reduces the system overhead by a small amount.

Content Provider

• A means for sharing tabular data across applications

• It is a class that implements a standard set of methods to let other applications store and retrieve the type of data that is handled by that content provider.

• Uses sqlite backend for relational data storage

Android User Interface• May be defined using XML files or by writing standard

java code

• XML Caveats– The XML parser and renderer have a lot of bugs.

This crashes eclipse alot. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical" android:layout_width="fill_parent“ android:layout_height="fill_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content“ android:text="Hello World"/>

</LinearLayout>

HINT: USE WRAP_CONTENT! WYSIWYG tool at droiddraw.org

Layouts• FrameLayout

– contains a single object• LinearLayout

– aligns all children in a single direction• TableLayout

– positions its children into rows and columns• AbsoluteLayout

– absolute positioningRelativeLayout

– children specify their position relative to the parent view or to each other

Handling UI events

• Handle events the standard way:• EventListeners

– onClick()• EventHandlers

– onTouchEvent(MotionEvent)

Crossing Things Off of Lists

Credit: Jeff Sharkeyhttp://www.jsharkey.org/blog

Further Reading

• http://developer.android.com• http://android-dls.com/wiki/• http://anddev.org• #android, #android-dev on

irc.openprojects.net

• http://source.android.com

Advanced Concepts

• http://www.v6pc.jp/apc/en/data/addressing.pdf

• http://www.open802.11s.org• http://www.quagga.net/about.php

top related