Slide 1ReferenceMobile OSWhat is Android?Why AndroidAndroid SDK FeatureToolsrun two networking emulators in a computer (Updated) - ADBMP1MP1 Project StructureAndroid Application ArchitectureAndroid Application ArchitectureViewView ComponentActivityUser Interaction EventApplication and Component GluesIntent (Cntd.)Intent from Peerlist to MessagingWorking in BackgroundServiceThreadingMP1 Threading StructurePeriodical Register with ServerActivity LifetimeDeclaration of App – Manifest.xmlExternal ResourcesDebugDebug on DeviceInstall package to Android PhonesOther TipsDemoDalvik Debug Monitoring ServiceAndroid Debug Bridge (ADB)BEGIN ANDROID JOURNEYIN HOURSCS425 / CSE 424 / ECE 428 [Fall 2009]Sept. 14, 2009Ying HuangREFERENCEOnline development guidehttp://developer.android.com/guide/index.htmlBook 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 OSSymbianiPhoneRIM's BlackBerryWindow mobileLinuxPalm webOSAndroid….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 kernelJava programmingOpen source libraries: SQLite, WebKit, OpenGLWHY ANDROIDA simple and powerful SDKNo licensing, distribution, or development feesDevelopment over many platform Linux, Mac OS, windows Excellent documentationThriving developer communityFor usJava-based, easy to import 3rd party Java libraryFunding (40+ G1 phones)Prize (amazon’s kindle)Job opportunityANDROID SDK FEATUREGSM, EDGE, and 3G networks, WiFi, BluetoothAPI Support for Bluetoothe, WiFi Ad hoc modeLibrariesMedia, SQLite, WebKit, SSLHardware control:Accelerometer, compass, microphone, camera, GPStouch screen, power Location-based service, map (Google API)MP3MP3TOOLSThe 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 machinesLogcat (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 shell commands.Traceview Graphical analysis tool for viewing the trace logs from your Android application Debug your application and profile its performanceMkSDCard Creates an SDCard disk image MP2RUN TWO NETWORKING EMULATORS IN A COMPUTER (UPDATED) - ADBQ: 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 forward1) Port forward to connect Android from localhostabd –s emulator-5554 forward tcp:15216 tcp:152162) Use a proxy server which can listen on my_public_ip:15216 and forward the data to localhost:15216stcppipe localhost 15216 15216E1E2M1MP1Underlying Infrastructure-based WiFi /TCP/IP Network G1 Phone (Peer)Peer RegistrationServerPeerPeerMP1 PROJECT STRUCTURERegistration PeerList MessagingANDROID APPLICATION ARCHITECTUREViews:Building block for user interface components.ActivitiesA single, focused thing that the user can do.Interaction with users: creating a window to place UIfull-screen windows, floating windows, embedded inside of another activityEx: Registration, Peerlist, Messaging GUIView Activity Intent Service Thread ResourceANDROID APPLICATION ARCHITECTUREServices (Background)Ex: Network OperationIntent Inter-communication among activities or servicesResourceExternalization of strings and graphicsNotificationsignaling users: Light, sound, icon, dialog, notificationEx: new message arrivesContent Providers share data between applicationsActivityActivityIntentView Activity Intent Service Thread ResourceVIEWLayout of visual interfaceJava Code Initialize Access TextView myTextView = (TextView)findViewById(R.id.myTextView);<?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>@Overridepublic void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.screen);}screen.xmlView Activity Intent Service Thread ResourceVIEW COMPONENTWidget ToolboxTextView, EditText,Button, Form, TimePicker…ListView (PeerList)Update list by arraysArrayAdaptermyListView.setAdapterLayoutPositions of controlsLinearLayout, Relativelayouthttp://developer.android.com/guide/tutorials/views/index.htmlMenuExit appView Activity Intent Service Thread ResourceACTIVITYForeground Activity: suspended when invisibleVisual, interactiveEx: Game, MapBackground Service: Little interaction Ex: Hardware, power managementIntermittent ActivityNotification, serviceExpects some interactivity but does most of its work in the background.NetworkOperation ManagementNetworkOperation ManagementRegistrationPeer ListMessagingView Activity Intent Service Thread ResourceUSER INTERACTION EVENT onKeyDown. onKeyUponTrackBallEventonTouchEventmyEditText.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; }});}registerButton.setOnClickListener(new OnClickListener() { public void onClick(View arg0) {….}}View Activity Intent Service Thread ResourceAPPLICATION AND COMPONENT GLUESAn intent is an abstract description of an operation to be performed.Launch an activityExplicitImplicit: Android selects the best startActivity();Subactivity: feedbackChild: use intent as feedback, setResultParent:
View Full Document