1. Trang chủ
  2. » Luận Văn - Báo Cáo

Begin android journey in hours (tutorials android

34 6 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Begin Android Journey In Hours
Tác giả Ying Huang
Trường học Standard format not all caps
Chuyên ngành Mobile Operating Systems
Thể loại Tutorial
Năm xuất bản 2009
Thành phố Standard format not all caps
Định dạng
Số trang 34
Dung lượng 0,91 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

T OOLS The Android Emulator  Implementation of the Android virtual machine  Test and debug your android applications..  Dalvik Debug Monitoring Service DDMS  Monitor and Control th

Trang 1

B EGIN A NDROID J OURNEY

I N H OUR S

CS425 / CSE 424 / ECE 428 [Fall 2009]

Sept 14, 2009 Ying Huang

Trang 2

R EFERENCE

 Online development guide

 http://developer.android.com/guide/index.html

 Book resource

amazon link)

Trang 4

W HAT IS A NDROID ?

Google OHA (Open Handset Alliance)

The first truly open and comprehensive platform for mobile devices, all of the software to run a mobile

phone but without the proprietary obstacles that have hindered mobile innovation.

Trang 5

W HY A NDROID

 A simple and powerful SDK

 No licensing, distribution, or development fees

 Development over many platform

Trang 6

A NDROID SDK F EATURE

 GSM, EDGE, and 3G networks, WiFi, Bluetooth

 Libraries

 Hardware control:

 Location-based service, map (Google API)

Trang 7

T OOLS

 The Android Emulator

 Implementation of the Android virtual machine

 Test and debug your android applications.

 Dalvik Debug Monitoring Service (DDMS)

 Monitor and Control the Dalvik virtual machines

 Logcat (see logged msgs)

 Android Debug Bridge (ADB)

 Manage the state of an emulator instance or Android-powered device

 Copy files, install compiled application packages, and run

Trang 8

RUN TWO NETWORKING EMULATORS IN A

 Q: run two networking emulators in a computer

A using the public IP address of A, during

debugging and demo?

 A1: telnet + redir (MP1 doc)

 A2: adb forward

 abd –s emulator-5554 forward tcp:15216 tcp:15216

my_public_ip:15216 and forward the data to

localhost:15216

 stcppipe localhost 15216 15216

M1

Trang 9

Underlying Infrastructure-based WiFi /TCP/IP Network

G1 Phone (Peer) Peer Registration

Server

Trang 10

MP1 PROJECT STRUCTURE

Trang 11

A NDROID A PPLICATION A RCHITECTURE

 Views:

 Activities

inside of another activity

 Ex: Registration, Peerlist, Messaging GUI

Trang 12

ANDROID APPLICATION ARCHITECTURE

Trang 13

android:layout_width=”fill_parent”

android:layout_height=”fill_parent”>

<TextView android:id=”@+id/myTextView”

android:layout_width=”fill_parent”

android:layout_height=”wrap_content” android:text=”Hello World, HelloWorld” />

Trang 15

A CTIVITY

 Foreground Activity: suspended when invisible

 Background Service : Little interaction

Registration

Peer List Messaging

Trang 16

U SER I NTERACTION E VENT

 onKeyDown onKeyUp

 onTrackBallEvent

 onTouchEvent

myEditText setOnKeyListener (new OnKeyListener () {

public boolean onKey (View v, int keyCode , KeyEvent event ) {

if (event.getAction() == KeyEvent.ACTION_DOWN)

if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {

Trang 17

A PPLICATION AND C OMPONENT G LUES

 An intent is an abstract description of an

Intent(Intent.ACTION_DIAL, Uri.parse(“tel:555-2368”));

Trang 18

Broadcast Receivers as being

capable of performing an action

on a particular kind of data

<activity …>

<intent-filter>

<action android:name=”com.paad.earthquake.inten t.action.SHOW_DAMAGE”>

</action>

<category android:name=”android.intent.category.DE FAULT”/>

<category android:name=”android.intent.category.AL TERNATIVE_SELECTED”/>

<data android:mimeType=”vnd.earthquake.cursor item/*”/>

Trang 19

INTENT FROM PEERLIST TO MESSAGING

Trang 21

S ERVICE

 Service class

 public class MyService extends Service

 public void onStart() {…}

Trang 22

T HREADING

 Respond to any user action within 5 seconds.

 A Broadcast Receiver must return within 10 seconds.

Trang 23

MP1 T HREADING S TRUCTURE

 Is it enough?

GUI Acitivty

Network Service

Server SocketServer SocketServer Socket

Spawn

Thread

Trang 24

P ERIODICAL R EGISTER WITH S ERVER

 Every 15 seconds

 How to update PeerList on PeerList GUI?

Timer

Trang 25

A CTIVITY L IFETIME

 Android apps do not control their lifetime

 Active (Foreground) Paused (FG, lose focus) Stopped (invisible) – Inactive (kill, exit)

-create Services

and threads

Broadcast Receivers exclusively used to update UI

threads, processes, or Broadcast Receivers

Trang 26

 Don’t forget Otherwise,

your socket programming

won’t run

Trang 29

D EBUG ON D EVICE

 On device

 Debug mode

 On desktop

 Connect your G1 with your PC

 When it asks for driver location choose

 For windows, android-sdk-windows-1.5_r3\usb_driver\x86\

 You'll see sth like "HTC Dream Composite ADB Interface"

Trang 30

I NSTALL PACKAGE TO A NDROID P HONES

 Compile the apk packages in Eclipse

 adb install …apk

Trang 31

O THER T IPS

In Eclipse, cmd-shift-o or ctrl-shift-o

 Start as early as possible

 P1: GUI, activity, intent

 P2: network service

 P3: integration

Trang 32

DEMO

Trang 33

DALVIK DEBUG MONITORING SERVICE

Trang 34

ANDROID DEBUG BRIDGE (ADB)

Ngày đăng: 28/09/2022, 11:16

TỪ KHÓA LIÊN QUAN

w