DOC PREVIEW
SDSU CS 696 - Android

This preview shows page 1-2-15-16-17-32-33 out of 33 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS 696 Emerging Web and Mobile TechnologiesSpring Semester, 2011Doc 17 AndroidMar 17, 2011Copyright ©, All rights reserved. 2011 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA. OpenContent (http://www.opencontent.org/opl.shtml) license defines the copyright on this document.Thursday, March 17, 2011References2Android Developer's Guide, http://developer.android.com/guide/index.htmlThursday, March 17, 2011Android3Googles mobile phone OS and SDKJava onlySpecial VMNonstandard byte codeEclipse is development IDELinuxApplication framework2D & 3D graphicsAudio, video and still image supportSQLite databaseEmbeddable web browserHardware dependentGSM, CDMABluetooth, EDGE, 3G, WIFICamera, GPS, compassaccelerometer, NFCThursday, March 17, 2011Android SDK4http://developer.android.com/guide/index.htmlSee Getting Started at Android DocsSupported OSWindows XP, VistaMac OS X 10.4.8 or later (intel processor only)Linux (Tested on Ubuntu Dapper Drake)IDEEclipse 3.3 or 3.4Java JDK 5 or JDK 6Current version 2.3.3 & 3.0Thursday, March 17, 2011Android 2.x verses 3.052.x for phonesRun on 3.0 devices Need some care to look reasonableCan provide several different layouts3.x for tabletsEmutalor - 4 mintues to startEmulator - 1 minute to startThursday, March 17, 2011Emulators6Very useful in developing applicationsNot the same as running on real deviceEmulator has bugsDevice has different bugsDevice has restriction and limitationsDevice as resources not on your development machineEclipse starts emulator when run Android appCan recompile and run app withoutexiting and restarting emulatorSlow to start upThursday, March 17, 20117Hello World Examplehttp://developer.android.com/sdk/index.htmlDownload AndroidFollow Hello World Tutorialhttp://developer.android.com/sdk/installing.htmlInstall Androidhttp://developer.android.com/resources/tutorials/hello-world.htmlThursday, March 17, 2011Hello World8Auto generated parts of applicationHelloAndroid.javaSource codeR.javaProvides access to resourcesResourcesicon.png (Application icon)main.xml (Optional Layout of application view)strings.xml (Allows separation of source code and display text)AndroidManifest.xmlDescribes application contentsThursday, March 17, 2011Hello.java9package sdsu.cs696;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android"); setContentView(tv); }}Thursday, March 17, 2011Bold text indicates text added or modified from auto-generated codePrintln does not work10package sdsu.cs696;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android"); setContentView(tv); System.out.println("Debug here"); }}Thursday, March 17, 2011Use Log11package edu.sdsu.cs;import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.widget.TextView;public class HelloWolrd extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android"); setContentView(tv); Log.i("Cat", "hello"); }}Thursday, March 17, 2011Building Android GUIs12In codeInstantiate GUI Widgets in codeIn XMLUse GUI builder in EclipseRaw XML in layout.xmlThursday, March 17, 2011Basic Android Application Parts 13ActivitiesUI building blockViews & Activity subclassesContent ProvidersShares data between applicationsIntentsSystem messagesServicesLong-running nonGUI codeFragmentsSub-activity UI containerAndroid 3.0Port pre-android 3 comingAndroidManifest.xmlR.javalayoutsThursday, March 17, 2011Things your program can use 14Data StorageSQL databaseNetwork AccessRaw socketsEmbeddable Web browserMultimediaSoundVideoGPSLocationPhone servicesThursday, March 17, 201115Basic Android Program PartsThursday, March 17, 2011AndroidManifest.xml16<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.hello2" android:versionCode="1" android:versionName="1.0.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloAndroid" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest> Contains information about the application needed by the phone to run itThursday, March 17, 2011@string/app_name indicates that the string is to be found in the string resource file under the label app_name.Views17ViewDisplays content in rectangular area of screenHandlesLayout, focus, scrollingKeyboard eventsGesturesViewGroupsManages set of views and view groupsComposite patternThursday, March 17, 2011Some Views18AutoCompleteTextViewButtonCheckBoxCheckedTextViewChronometerDatePickerDigitalClockEditTextExpandableListViewGalleryGridViewImageButtonListViewMapView,MultiAutoCompleteTextViewRadioButtonRatingBarScrollViewSeekBarSpinnerTabHostTabWidgetTableRowTimePickerToggleButtonTwoLineListItemVideoViewViewAnimatorWebViewZoomButtonZoomControlsThursday, March 17, 2011Activity19Code that does some workSingle, focused thing that a user can doUsually each screen(View) has its own activityAn application may have multiple screens, hence multiple activitiesAn application runs in its own Linux processActivities can be viewlessThursday, March 17, 2011Activity Lifecycle States20Active (Resumed)Running activity in foreground of screenPausedLost focus, but still visibleRetains all state informationIn extreme memory situations may be killedStoppedNot visibleRetains all state informationOften will be killedThursday, March 17, 201121Thursday, March 17, 201122LifeCycle Methodspublic class ExampleActivity extends Activity { public void onCreate(Bundle savedInstanceState) {


View Full Document

SDSU CS 696 - Android

Download Android
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Android and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Android 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?