Download presentation
Presentation is loading. Please wait.
Published byLydia Capers Modified over 10 years ago
1
ANDROID DEVELOPMENT KELLY MCBEAN
2
DEVELOPMENT ENVIRONMENT OVERVIEW Eclipse Standard IDE for Developing Android Applications Install: 1.Java (JDK) – Since Eclipse Runs on top of Java 2.Eclipse Standard 3.Using Eclipse Install Software 1.Developer Tools (Plugins) 2.Android SDK 3.Android APIs
3
TESTING FOR JAVA http://java.com If you get the Congratulations message, skip to Installing Eclipse…else continue with the Java Install
4
INSTALLING JAVA Install Documentation: http://developer.android.com/sdk/installing.html Java Platform (JDK) http://www.oracle.com/technetwork/java/javase/downloads/index.html
5
INSTALLING JAVA Install latest version * for appropriate OS * At this time 7u25 is the latest
6
INSTALLING ECLIPSE Downloads: http://www.eclipse.org/downloads Install: 1.Save file to a temp folder 2.Open Zip file and copy the eclipse to root (c:\) 3.Run eclipse from c:\eclipse\eclipse.exe 4.Accept the default workspace
7
INSTALLING PLUG-IN From Inside Eclipse: Menu: Help > Install New Software… Work with: http://dl.google/android/eclipse After Accepting License Agreement Eclipse will reboot and continue with installing SDK
8
INSTALLING SDK Note the Target Location Accept All And Wait…
9
INSTALLING API The Android APIs are the Android platforms (i.e. 2.2, 4.1, etc.) By Default, only One API is installed To check on Installed Android APIs: Windows > Preferences Android Tab Optional: Menu: Windows > Android SDK Manager Choose Additional APIs to Install
10
VIRTUAL DEVICES (AVD) The AVD is an emulator instance that enables you to model an actual device APIs are available to emulate many of the most popular Android devices While tethering a device through a USB connection is possible, AVDs are invaluable for testing applications
11
CREATING A VIRTUAL DEVICE The AVD is an emulator instance that enables you to model an actual device You will need one for each API you want to test… Menu: Windows > AVD Manager
12
UPDATE ENVIRONMENT PATH My Computer. Properties. Advanced Add C:\android-sdks\tools; C:\android-sdks\platform- tools to … Environment. System. Path Optional?
13
ECLIPSE DEVELOPMENT ENVIRONMENT FOR ANDROID The Eclipse Development Environment should be ready to go…
14
CREATING ANDROID APPLICATION Application Name is shown in Play Store Project Name must be unique within Android Workspace Package Name is a Unique Identifier for the Application
15
ANDROID PLATFORM DISTRIBUTION
16
ANATOMY OF AN ANDROID APPLICATION src – Contains the Java source files for the project gen – Contains the R.java file, a compiler- generated file that references all the project resources res – All the project resources. Also contains subfolders to support devices with different size screen resolutions and densities values – Contains string constants for the application AndroidManifest – The manifest for the Android application includes the Intents for the Activities and any permissions needed by the application
17
ACTIVITIES AND INTENTS An Activity is a window that contains the user interface An application can have zero or more activities In Android, you navigate between Activities through what is known as an intent Intents enable different activities from different applications to work together
18
DIALOG WINDOWS o Dialog windows are used to display information and sometimes to get confirmation from the user o Common Dialog Windows consist of: o Toast o A message that pops up on the bottom of the user screen for a short period of time o Alert Dialog Window o Displays choices to the user and waits for a response o Progress Dialog Window o Useful for displaying the progress of a process
19
TOAST DIALOG A toast provides simple feedback in a small popup Toasts take 3 parameters 1)Application Context 2)Text Message 3)Duration OR
20
ALERT DIALOG Alert Dialog gets a confirmation from the user Code to handle the following events Positive: Typically OK Negative: Typically Cancel MultiChoice: When the user selects from a list
21
PROGRESS DIALOG
22
INTENTS o In Android, you navigate between activities through what is known as an intent o Results can be returned from an Intent o Data can also be passed using Intent Object o Built-in applications can be called using Intents o Web Browser o Phone Dialer o Contacts o Map o Etc.
23
WEB BROWSER & PHONE INTENT
24
NOTIFICATIONS A notification is a message displayed to the user outside of the applications UI To see the details of the notification, the user opens the notification drawer This is the old way of calling notifications but still works…
25
NOTIFICATIONS o Activity to receive the notification is just a single TextView
26
BREAK
27
RECAP Installing and Configuring the IDE Java (JDK) Eclipse Plug-Ins SDKs APIs The UI screen for Android Applications are called Activities Intents are used to link Activities There are built-In Intents (Browser, Contacts, Etc.) Dialog Windows Toasts Alerts Progress Notifications
28
USER INTERFACE (ACTIVITIES) An Activity is a window that contains the user interface (Views and ViewGroups) o Views consist of o TextViews (labels) o TextEdits (text boxs) o Radio Buttons o Check Boxes o Date Pickers o Time Pickers o Etc.
29
USER INTERFACE (ACTIVITIES) ViewGroups are layouts used to arrange Views into proper location on the screen o Android supports the following ViewGroups Linear Layouts Absolute Layout Table Layout Relative Layout Frame Layout Scroll View o ViewGroups can be nested
30
VIEWGROUPS (LINEAR LAYOUT) o The Linear Layout Stacks Views on top of each other o Orientation can be Vertical (default) or Horizontal View Linear Layout View Linear Layout
31
VIEWGROUPS (LINEAR LAYOUT)
32
VIEWGROUPS (RELATIVE LAYOUT) o The Relative Layout arranges Views in relation to the parent or other Views Relative Layout View
33
VIEWGROUPS (RELATIVE LAYOUT)
34
VIEWGROUPS (SCROLLVIEW) o The ScrollView enables users to scroll through a list of Views that occupy more space than the physical display o The ScrollView can only have one child, typically a Linear Layout ScrollView Linear Layout View
35
VIEWGROUPS (SCROLLVIEW)
36
ANCHORING VIEWS
37
CUSTOM ORIENTATIONS SCREENS o A preferable alternate to anchoring is to create custom screens based on orientation o To support Landscape mode, create a new folder in the res folder named layout-land o Layouts contained in the layout folder defines the UI for portrait mode o Layouts contained in the layout-land folder defines the UI for landscape mode
38
CUSTOM LANDSCAPE UI
39
PERSISTING STATE INFORMATION o Changing screen orientation destroys the Activity and re-creates it o Current state of the Activity is lost o When an Activity is killed, itll fire the onPause and onSaveInstanceState events o You can implement the onPause event to save state information to database, internal or external storage Or o Implement the onSaveInstanceState event and save the state using Bundle object o After the activity is re-recreated retrieve and reset the state in the onRestoreInstanceState event
40
PERSISTING STATE INFORMATION Flow: o Orientation Changes o Activity is Killed o Activity is re-created o State information McBean is lost
41
ACTIVITY LIFE CYCLE o These are the major events triggered during the life cycle of an Activity Additionally o onRestoreInstanceState occurs after onStart o onSaveInstanceState occurs after onPause
42
PERSISTING STATE INFORMATION
43
REGISTERING EVENTS FOR VIEWS o Views can fire events when user interacts with them o The appropriate events need to be explicitly registered o Events can be registered using an inner class or an anonymous class
44
REGISTERING EVENTS FOR VIEWS o Using the AnchorView as an example o The buttons are linked to the UI buttons using findViewById o The setOnClickListener gives the buttons ears to listen for the click event to be triggered by the user o btn1…btn4 call an anonymous class btnListener o Btn5 calls an inner class
45
BASIC VIEWS Views commonly used are: TextView – Display Information EditText – Allows user to key in Information CheckBox – Turn on and off RadioButtons – Select one in a list ToggleButton – Turn on and off
46
SIMPLE LIST VIEW o The ListView displays a long list of items in an Activity o No UI Layout Required o Presentation is dictated by the second parameter of the setListAdapter
47
CUSTOM LIST VIEW o Colleges array was moved to strings.xml file and now called as a resource
48
SPINNER VIEW Similar to the ListView except is used when other Views will be displayed on the UI
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.