SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
BEGIN ANDROID JOURNEY
IN HOURS
CS425 / CSE 424 / ECE 428 [Fall 2009]

Sept. 14, 2009
Ying Huang
REFERENCE


Online development guide




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

Book resource

“Professional Android Application Development”, by
Reto Meier, (Wrox, amazon link)
 “Android A programmers guide”, by J.F. DiMarzio,
(McGraw Hill, amazon link)
 “Beginning.Android”, by Mark L. Murphy, (Apress,
amazon link)
 “Pro Android”, by Sayed Y. Hashimi, Satya
Komatineni, (Apress, amazon link)

MOBILE OS
Symbian
 iPhone
 RIM's BlackBerry
 Window mobile
 Linux
 Palm webOS
 Android
 ….

WHAT IS ANDROID?


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.

Linux OS kernel
 Java programming
 Open source libraries: SQLite, WebKit, OpenGL

WHY ANDROID
A simple and powerful SDK
 No licensing, distribution, or development fees
 Development over many platform




Linux, Mac OS, windows

Excellent documentation
 Thriving developer community




For us

Java-based, easy to import 3rd party Java library
 Funding (40+ G1 phones)
 Prize (amazon’s kindle)
 Job opportunity

ANDROID SDK FEATURE


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



Libraries




API Support for Bluetoothe, WiFi Ad hoc mode
Media, SQLite, WebKit, SSL

Hardware control:

Accelerometer, compass, microphone, camera, GPS
 touch screen, power




Location-based service, map (Google API)
TOOLS


The Android Emulator









Implementation of the Android virtual machine
Test and debug your android applications.
Monitor and Control the Dalvik virtual machines
Logcat (see logged msgs)

Dalvik Debug Monitoring Service (DDMS)
Android Debug Bridge (ADB)

Manage the state of an emulator instance or Android-powered
device
 Copy files, install compiled application packages, and run
shell commands.




Traceview

Graphical analysis tool for viewing the trace logs from your
Android application
 Debug your application and profile its performance




MkSDCard


Creates an SDCard disk image
RUN TWO NETWORKING EMULATORS IN A
COMPUTER (UPDATED) - ADB


Q: run two networking emulators in a computer
A using the public IP address of A, during
debugging and demo?
E1



A1: telnet + redir (MP1 doc)



A2: adb forward


1) Port forward to connect Android from localhost




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



stcppipe localhost 15216 15216

2) Use a proxy server which can listen on
my_public_ip:15216 and forward the data to
localhost:15216

M1

E2
MP1
Peer Registration
Server

G1 Phone (Peer)

Underlying
Infrastructure-based
WiFi /TCP/IP Network

Peer

Peer
MP1 PROJECT STRUCTURE

Registration

PeerList

Messaging
View

Activity

Intent

Service

Thread

Resource

ANDROID APPLICATION ARCHITECTURE


Views:




Building block for user interface components.

Activities

A single, focused thing that the user can do.
 Interaction with users: creating a window to place UI
 full-screen windows, floating windows, embedded
inside of another activity
 Ex: Registration, Peerlist, Messaging GUI

View

Activity

Intent

Service

Thread

Resource

ANDROID APPLICATION ARCHITECTURE


Services (Background)




Intent




Externalization of strings and graphics

Notification

signaling users: Light, sound, icon, dialog,
notification
 Ex: new message arrives




Content Providers


Intent

Inter-communication among activities or services

Resource




Ex: Network Operation

Activity

share data between applications

Activity
View

Activity

Intent

Service

Thread

VIEW


Layout of visual interface



Java Code


Initialize

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.screen);
}


Access

TextView myTextView =
(TextView)findViewById(R.id.myTextView);

Resource

screen.xml
<?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:id=”@+id/myTextView”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”Hello World, HelloWorld”
/>
</LinearLayout>
View

Activity

Intent

Service

Thread

Resource

VIEW COMPONENT
 Widget




TextView, EditText,Button, Form, TimePicker…
ListView (PeerList)


Update list by arrays





Toolbox

ArrayAdapter
myListView.setAdapter

Layout

Positions of controls
 LinearLayout, Relativelayout




http://developer.android.com/guide/tutorials/views/index.html

 Menu



Exit app
View

Activity

Intent

Service

Thread

Resource

ACTIVITY


Foreground Activity: suspended when invisible
Visual, interactive
 Ex: Game, Map




Background Service: Little interaction




Ex: Hardware, power management

Intermittent Activity

Registration
Peer List
Messaging
Network
Operation
Management

Notification, service
 Expects some interactivity but does most of its work
in the background.

View

Activity

Intent

Service

Thread

Resource

USER INTERACTION EVENT




onKeyDown. onKeyUp
onTrackBallEvent
onTouchEvent

registerButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {….}}
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)
{
…
return true;
}
return false;
}});}
View

Activity

Intent

Service

Thread

Resource

APPLICATION AND COMPONENT GLUES


An intent is an abstract description of an
operation to be performed. Ex: Intent intent = new


Launch an activity


Explicit

Intent(MyActivity.this, MyOtherActivity.class);
Im: Intent intent = new
Intent(Intent.ACTION_DIAL,
Uri.parse(“tel:555-2368”));

Implicit: Android selects the best
 startActivity();




Subactivity: feedback

Child: use intent as feedback, setResult
 Parent: onActivityResult
 startActivityForResult




Action, data, extra parameter


intent.putExtra(name, property);
View

Activity

Intent

Service

Thread

Resource

INTENT (CNTD.)


Broadcast

announce application events
system-wide
 sendBroadcast
 MyBroadcastReceiver extends
BroadcastReceiver
 registerReceiver (in java / in xml)




Intent Filter


Register Activities, Services, and
Broadcast Receivers as being
capable of performing an action
on a particular kind of data.

Manifest.xml
<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/*”/>
</intent-filter>
</activity>
View

Activity

Intent

Service

Thread

Resource

INTENT FROM PEERLIST TO MESSAGING

Select a peer
Send Intent

PeerList

Messaging
View

Activity

Intent

Service

Thread

Resource

WORKING IN BACKGROUND


Services

NO GUI, higher priority than inactive Activities
 Usage:








responding to events, polling for data, updating Content
Providers.

However, all in the main thread

Background threads
View

Activity

Intent

Service

Thread

Resource

SERVICE


Service class





Manifest.xml




<service android:enabled=”true”
android:name=”.MyService”></service>

Control





public class MyService extends Service
public void onStart() {…}

startService
stopService

Communication

Bind service with activity: use public method and
properties
 Intent

THREADING


Being Responsive (1sec)





What to thread?




Respond to any user action within 5 seconds.
A Broadcast Receiver must return within 10
seconds.

Network, file IO, Complex processing

How?

New Thread
 Synchronize threads




Handler.post()
MP1 THREADING STRUCTURE


Is it enough?
Server
Server
Socket
Server
Socket
Socket
GUI
Acitivty

Network
Service

Spawn

Thread
PERIODICAL REGISTER WITH SERVER


Every 15 seconds

Timer



How to update PeerList on PeerList GUI?


Intent
ACTIVITY LIFETIME




Android apps do not control their lifetime.
Active (Foreground) - Paused (FG, lose focus) Stopped (invisible) – Inactive (kill, exit)

create Services
and threads

threads, processes, or
Broadcast Receivers

Broadcast Receivers
exclusively used to update UI
DECLARATION OF APP – MANIFEST.XML


Service



Activity (intent-filter)



Permission


Don’t forget. Otherwise,
your socket programming
won’t run

<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1“ android:versionName="1.0“
package="com.uiuc.cs425">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">

<
android:name=".services.IMService" />
<activity android:name=".Register">
<
>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.
</intent-filter>
</activity>
<activity android:name=".PeerList">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.
</intent-filter>
</activity>
<activity android:name=".Messaging">
…
</activity>
</application>
…
<uses-permission android:name="android.permission.
<uses-permission
android:name="android.permission.
</manifest>

/>

" />

/>
" />
View

Activity

Intent

Service

Thread

Resource

EXTERNAL RESOURCES


values/




drawables/




String, color, array, dimension, style theme
Image

layout/


screen.xml
DEBUG
System.err.println()
 Package - android.util.Log




View results

Logcat
 Eclipse IDE

DEBUG ON DEVICE


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_r3usb_driverx86

You'll see sth like "HTC Dream Composite ADB Interface"
on success
 (Re)Start Eclipse
 Your G1 should now be listed in the DDMS-Perspective
under Device




Reference: [http://www.anddev.org/debugginginstalling_apps_on_the_g1_windows_drivert3236.html]
INSTALL PACKAGE TO ANDROID PHONES


Compile the apk packages in Eclipse




Export signed application package

adb install …apk


Error: uninstall
OTHER TIPS




Automatic imports of packages
In Eclipse, cmd-shift-o or ctrl-shift-o
Start as early as possible


Possible task partition for a group
P1: GUI, activity, intent
 P2: network service
 P3: integration

DEMO
DALVIK DEBUG MONITORING SERVICE
ANDROID DEBUG BRIDGE (ADB)

Weitere ähnliche Inhalte

Was ist angesagt?

Android tutorial
Android tutorialAndroid tutorial
Android tutorialmaster760
 
Intro To Android App Development
Intro To Android App DevelopmentIntro To Android App Development
Intro To Android App DevelopmentMike Kvintus
 
Android - From Zero to Hero @ DEVit 2017
Android - From Zero to Hero @ DEVit 2017Android - From Zero to Hero @ DEVit 2017
Android - From Zero to Hero @ DEVit 2017Ivo Neskovic
 
Android application-component
Android application-componentAndroid application-component
Android application-componentLy Haza
 
Android application structure
Android application structureAndroid application structure
Android application structureAlexey Ustenko
 
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]Sittiphol Phanvilai
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from ScratchTaufan Erfiyanto
 
Android Development Training
Android Development TrainingAndroid Development Training
Android Development Trainingchandutata
 
Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Joemarie Amparo
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Developmentdonnfelker
 
Android architecture
Android architecture Android architecture
Android architecture Trong-An Bui
 
Introduction to Android development - Presentation
Introduction to Android development - PresentationIntroduction to Android development - Presentation
Introduction to Android development - PresentationAtul Panjwani
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersBoom Shukla
 
Introduction to Android App Development
Introduction to Android App DevelopmentIntroduction to Android App Development
Introduction to Android App DevelopmentTodd Burgess
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentAly Abdelkareem
 
Live Streaming Application Development
Live Streaming Application DevelopmentLive Streaming Application Development
Live Streaming Application DevelopmentMarie Weaver
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a NutshellAleix Solé
 

Was ist angesagt? (20)

Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Intro To Android App Development
Intro To Android App DevelopmentIntro To Android App Development
Intro To Android App Development
 
Android - From Zero to Hero @ DEVit 2017
Android - From Zero to Hero @ DEVit 2017Android - From Zero to Hero @ DEVit 2017
Android - From Zero to Hero @ DEVit 2017
 
Android application-component
Android application-componentAndroid application-component
Android application-component
 
Android application structure
Android application structureAndroid application structure
Android application structure
 
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from Scratch
 
Android Development Training
Android Development TrainingAndroid Development Training
Android Development Training
 
Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1
 
Android beginners David
Android beginners DavidAndroid beginners David
Android beginners David
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android architecture
Android architecture Android architecture
Android architecture
 
Google Android
Google AndroidGoogle Android
Google Android
 
Introduction to Android development - Presentation
Introduction to Android development - PresentationIntroduction to Android development - Presentation
Introduction to Android development - Presentation
 
Android fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginnersAndroid fundamentals and tutorial for beginners
Android fundamentals and tutorial for beginners
 
Introduction to Android App Development
Introduction to Android App DevelopmentIntroduction to Android App Development
Introduction to Android App Development
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android
AndroidAndroid
Android
 
Live Streaming Application Development
Live Streaming Application DevelopmentLive Streaming Application Development
Live Streaming Application Development
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a Nutshell
 

Andere mochten auch

Introduction to Android development - CEC ISQIP 2014
Introduction to Android development -  CEC ISQIP 2014Introduction to Android development -  CEC ISQIP 2014
Introduction to Android development - CEC ISQIP 2014Melson Zacharias
 
Basics of Android
Basics of Android Basics of Android
Basics of Android sabi_123
 
Introduction to android basics
Introduction to android basicsIntroduction to android basics
Introduction to android basicsHasam Panezai
 
Learn Android app development in easy steps
Learn Android app development in easy stepsLearn Android app development in easy steps
Learn Android app development in easy stepsMobile Pundits
 

Andere mochten auch (7)

Android
AndroidAndroid
Android
 
Introduction to Android development - CEC ISQIP 2014
Introduction to Android development -  CEC ISQIP 2014Introduction to Android development -  CEC ISQIP 2014
Introduction to Android development - CEC ISQIP 2014
 
Basics of Android
Basics of Android Basics of Android
Basics of Android
 
Android Basics
Android BasicsAndroid Basics
Android Basics
 
Android Basics
Android BasicsAndroid Basics
Android Basics
 
Introduction to android basics
Introduction to android basicsIntroduction to android basics
Introduction to android basics
 
Learn Android app development in easy steps
Learn Android app development in easy stepsLearn Android app development in easy steps
Learn Android app development in easy steps
 

Ähnlich wie Android Basics

Getting Started with Android 1.5
Getting Started with Android 1.5Getting Started with Android 1.5
Getting Started with Android 1.5Gaurav Kohli
 
Android presentation
Android presentationAndroid presentation
Android presentationImam Raza
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspectiveGunjan Kumar
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentProf. Erwin Globio
 
Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Lars Vogel
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologiesjerry vasoya
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Androidguest213e237
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentalsAmr Salman
 
Android overview
Android overviewAndroid overview
Android overviewHas Taiar
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A NutshellTed Chien
 

Ähnlich wie Android Basics (20)

Getting Started with Android 1.5
Getting Started with Android 1.5Getting Started with Android 1.5
Getting Started with Android 1.5
 
Android presentation
Android presentationAndroid presentation
Android presentation
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspective
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Android TCJUG
Android TCJUGAndroid TCJUG
Android TCJUG
 
Android overview
Android overviewAndroid overview
Android overview
 
Android Minnebar
Android MinnebarAndroid Minnebar
Android Minnebar
 
Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11 Android Introduction on Java Forum Stuttgart 11
Android Introduction on Java Forum Stuttgart 11
 
Android terminologies
Android terminologiesAndroid terminologies
Android terminologies
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Android
 
Android app fundamentals
Android app fundamentalsAndroid app fundamentals
Android app fundamentals
 
PPT Companion to Android
PPT Companion to AndroidPPT Companion to Android
PPT Companion to Android
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android Intro
Android IntroAndroid Intro
Android Intro
 
Android intro
Android introAndroid intro
Android intro
 
Android Anatomy
Android  AnatomyAndroid  Anatomy
Android Anatomy
 
Android overview
Android overviewAndroid overview
Android overview
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A Nutshell
 
Android
AndroidAndroid
Android
 
Android
AndroidAndroid
Android
 

Kürzlich hochgeladen

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Kürzlich hochgeladen (20)

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

Android Basics

  • 1. BEGIN ANDROID JOURNEY IN HOURS CS425 / CSE 424 / ECE 428 [Fall 2009] Sept. 14, 2009 Ying Huang
  • 2. REFERENCE  Online development guide   http://developer.android.com/guide/index.html Book resource “Professional Android Application Development”, by Reto Meier, (Wrox, amazon link)  “Android A programmers guide”, by J.F. DiMarzio, (McGraw Hill, amazon link)  “Beginning.Android”, by Mark L. Murphy, (Apress, amazon link)  “Pro Android”, by Sayed Y. Hashimi, Satya Komatineni, (Apress, amazon link) 
  • 3. MOBILE OS Symbian  iPhone  RIM's BlackBerry  Window mobile  Linux  Palm webOS  Android  …. 
  • 4. WHAT IS ANDROID?  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. Linux OS kernel  Java programming  Open source libraries: SQLite, WebKit, OpenGL 
  • 5. WHY ANDROID A simple and powerful SDK  No licensing, distribution, or development fees  Development over many platform   Linux, Mac OS, windows Excellent documentation  Thriving developer community   For us Java-based, easy to import 3rd party Java library  Funding (40+ G1 phones)  Prize (amazon’s kindle)  Job opportunity 
  • 6. ANDROID SDK FEATURE  GSM, EDGE, and 3G networks, WiFi, Bluetooth   Libraries   API Support for Bluetoothe, WiFi Ad hoc mode Media, SQLite, WebKit, SSL Hardware control: Accelerometer, compass, microphone, camera, GPS  touch screen, power   Location-based service, map (Google API)
  • 7. TOOLS  The Android Emulator       Implementation of the Android virtual machine Test and debug your android applications. Monitor and Control the Dalvik virtual machines Logcat (see logged msgs) Dalvik Debug Monitoring Service (DDMS) Android Debug Bridge (ADB) Manage the state of an emulator instance or Android-powered device  Copy files, install compiled application packages, and run shell commands.   Traceview Graphical analysis tool for viewing the trace logs from your Android application  Debug your application and profile its performance   MkSDCard  Creates an SDCard disk image
  • 8. RUN TWO NETWORKING EMULATORS IN A COMPUTER (UPDATED) - ADB  Q: run two networking emulators in a computer A using the public IP address of A, during debugging and demo? E1  A1: telnet + redir (MP1 doc)  A2: adb forward  1) Port forward to connect Android from localhost   abd –s emulator-5554 forward tcp:15216 tcp:15216  stcppipe localhost 15216 15216 2) Use a proxy server which can listen on my_public_ip:15216 and forward the data to localhost:15216 M1 E2
  • 9. MP1 Peer Registration Server G1 Phone (Peer) Underlying Infrastructure-based WiFi /TCP/IP Network Peer Peer
  • 11. View Activity Intent Service Thread Resource ANDROID APPLICATION ARCHITECTURE  Views:   Building block for user interface components. Activities A single, focused thing that the user can do.  Interaction with users: creating a window to place UI  full-screen windows, floating windows, embedded inside of another activity  Ex: Registration, Peerlist, Messaging GUI 
  • 12. View Activity Intent Service Thread Resource ANDROID APPLICATION ARCHITECTURE  Services (Background)   Intent   Externalization of strings and graphics Notification signaling users: Light, sound, icon, dialog, notification  Ex: new message arrives   Content Providers  Intent Inter-communication among activities or services Resource   Ex: Network Operation Activity share data between applications Activity
  • 13. View Activity Intent Service Thread VIEW  Layout of visual interface  Java Code  Initialize @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.screen); }  Access TextView myTextView = (TextView)findViewById(R.id.myTextView); Resource screen.xml <?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:id=”@+id/myTextView” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”Hello World, HelloWorld” /> </LinearLayout>
  • 14. View Activity Intent Service Thread Resource VIEW COMPONENT  Widget   TextView, EditText,Button, Form, TimePicker… ListView (PeerList)  Update list by arrays    Toolbox ArrayAdapter myListView.setAdapter Layout Positions of controls  LinearLayout, Relativelayout   http://developer.android.com/guide/tutorials/views/index.html  Menu  Exit app
  • 15. View Activity Intent Service Thread Resource ACTIVITY  Foreground Activity: suspended when invisible Visual, interactive  Ex: Game, Map   Background Service: Little interaction   Ex: Hardware, power management Intermittent Activity Registration Peer List Messaging Network Operation Management Notification, service  Expects some interactivity but does most of its work in the background. 
  • 16. View Activity Intent Service Thread Resource USER INTERACTION EVENT    onKeyDown. onKeyUp onTrackBallEvent onTouchEvent registerButton.setOnClickListener(new OnClickListener() { public void onClick(View arg0) {….}} 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) { … return true; } return false; }});}
  • 17. View Activity Intent Service Thread Resource APPLICATION AND COMPONENT GLUES  An intent is an abstract description of an operation to be performed. Ex: Intent intent = new  Launch an activity  Explicit Intent(MyActivity.this, MyOtherActivity.class); Im: Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(“tel:555-2368”)); Implicit: Android selects the best  startActivity();   Subactivity: feedback Child: use intent as feedback, setResult  Parent: onActivityResult  startActivityForResult   Action, data, extra parameter  intent.putExtra(name, property);
  • 18. View Activity Intent Service Thread Resource INTENT (CNTD.)  Broadcast announce application events system-wide  sendBroadcast  MyBroadcastReceiver extends BroadcastReceiver  registerReceiver (in java / in xml)   Intent Filter  Register Activities, Services, and Broadcast Receivers as being capable of performing an action on a particular kind of data. Manifest.xml <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/*”/> </intent-filter> </activity>
  • 19. View Activity Intent Service Thread Resource INTENT FROM PEERLIST TO MESSAGING Select a peer Send Intent PeerList Messaging
  • 20. View Activity Intent Service Thread Resource WORKING IN BACKGROUND  Services NO GUI, higher priority than inactive Activities  Usage:     responding to events, polling for data, updating Content Providers. However, all in the main thread Background threads
  • 21. View Activity Intent Service Thread Resource SERVICE  Service class    Manifest.xml   <service android:enabled=”true” android:name=”.MyService”></service> Control    public class MyService extends Service public void onStart() {…} startService stopService Communication Bind service with activity: use public method and properties  Intent 
  • 22. THREADING  Being Responsive (1sec)    What to thread?   Respond to any user action within 5 seconds. A Broadcast Receiver must return within 10 seconds. Network, file IO, Complex processing How? New Thread  Synchronize threads   Handler.post()
  • 23. MP1 THREADING STRUCTURE  Is it enough? Server Server Socket Server Socket Socket GUI Acitivty Network Service Spawn Thread
  • 24. PERIODICAL REGISTER WITH SERVER  Every 15 seconds Timer  How to update PeerList on PeerList GUI?  Intent
  • 25. ACTIVITY LIFETIME   Android apps do not control their lifetime. Active (Foreground) - Paused (FG, lose focus) Stopped (invisible) – Inactive (kill, exit) create Services and threads threads, processes, or Broadcast Receivers Broadcast Receivers exclusively used to update UI
  • 26. DECLARATION OF APP – MANIFEST.XML  Service  Activity (intent-filter)  Permission  Don’t forget. Otherwise, your socket programming won’t run <?xml version="1.0" encoding="utf-8" ?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1“ android:versionName="1.0“ package="com.uiuc.cs425"> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> < android:name=".services.IMService" /> <activity android:name=".Register"> < > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category. </intent-filter> </activity> <activity android:name=".PeerList"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category. </intent-filter> </activity> <activity android:name=".Messaging"> … </activity> </application> … <uses-permission android:name="android.permission. <uses-permission android:name="android.permission. </manifest> /> " /> /> " />
  • 28. DEBUG System.err.println()  Package - android.util.Log   View results Logcat  Eclipse IDE 
  • 29. DEBUG ON DEVICE  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_r3usb_driverx86 You'll see sth like "HTC Dream Composite ADB Interface" on success  (Re)Start Eclipse  Your G1 should now be listed in the DDMS-Perspective under Device   Reference: [http://www.anddev.org/debugginginstalling_apps_on_the_g1_windows_drivert3236.html]
  • 30. INSTALL PACKAGE TO ANDROID PHONES  Compile the apk packages in Eclipse   Export signed application package adb install …apk  Error: uninstall
  • 31. OTHER TIPS   Automatic imports of packages In Eclipse, cmd-shift-o or ctrl-shift-o Start as early as possible  Possible task partition for a group P1: GUI, activity, intent  P2: network service  P3: integration 
  • 32. DEMO