1 / 48

Android Development

Android Development . Kelly McBean. Development Environment Overview. Eclipse Standard IDE for Developing Android Applications Install: Java (JDK) – Since Eclipse Runs on top of Java Eclipse Standard Using Eclipse “Install Software” Developer Tools (Plugins) Android SDK

elkan
Download Presentation

Android Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Android Development Kelly McBean

  2. Development EnvironmentOverview • Eclipse • Standard IDE for Developing Android Applications • Install: • Java (JDK) – Since Eclipse Runs on top of Java • Eclipse Standard • Using Eclipse “Install Software” • Developer Tools (Plugins) • Android SDK • Android APIs

  3. http://java.com Testing for Java 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. Install latest version * for appropriate OS * At this time 7u25 is the latest Installing Java

  6. Downloads: • http://www.eclipse.org/downloads • Install: • Save file to a temp folder • Open Zip file and copy the eclipse to root (c:\) • Run eclipse from c:\eclipse\eclipse.exe • Accept the default workspace Installing Eclipse

  7. From Inside Eclipse: • Menu: Help > Install New Software… • Work with: http://dl.google/android/eclipse Installing Plug-in After Accepting License Agreement Eclipse will reboot and continue with installing SDK

  8. Note the Target Location Installing SDK Accept All And Wait…

  9. 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 Installing API Optional: Menu: Windows > Android SDK Manager Choose Additional APIs to Install

  10. 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 Virtual Devices (AVD)

  11. The AVD is an emulator instance that enables you to model an actual device Creating a Virtual Device Menu: Windows > AVD Manager You will need one for each API you want to test…

  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 are used to display information and sometimes to get confirmation from the user • Common Dialog Windows consist of: • Toast • A message that pops up on the bottom of the user screen for a short period of time • Alert Dialog Window • Displays choices to the user and waits for a response • Progress Dialog Window • Useful for displaying the progress of a process Dialog Windows

  19. A toast provides simple feedback in a small popup • Toasts take 3 parameters • Application Context • Text Message • Duration Toast Dialog OR

  20. 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 Alert Dialog

  21. Progress Dialog

  22. In Android, you navigate between activities through what is known as an intent • Results can be returned from an Intent • Data can also be passed using Intent Object • Built-in applications can be called using Intents • Web Browser • Phone Dialer • Contacts • Map • Etc. INtents

  23. Web browser & Phone intent

  24. 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 Notifications • This is the old way of calling notifications but still works…

  25. Activity to receive the notification is just a single TextView Notifications

  26. Break

  27. 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 Recap

  28. An Activity is a window that contains the user interface (Views and ViewGroups) • Views consist of • TextViews (labels) • TextEdits (text boxs) • Radio Buttons • Check Boxes • Date Pickers • Time Pickers • Etc. User interface (Activities)

  29. ViewGroups are layouts used to arrange Views into proper location on the screen • Android supports the following ViewGroups • Linear Layouts • Absolute Layout • Table Layout • Relative Layout • Frame Layout • Scroll View • ViewGroups can be nested User interface (Activities)

  30. The Linear Layout Stacks Views on top of each other • Orientation can be Vertical (default) or Horizontal Viewgroups (Linear Layout) Linear Layout View Linear Layout View View View View View

  31. Viewgroups (Linear Layout)

  32. The Relative Layout arranges Views in relation to the parent or other Views Viewgroups (Relative Layout) Relative Layout View View View View View View View

  33. Viewgroups (Relative Layout)

  34. The ScrollView enables users to scroll through a list of Views that occupy more space than the physical display • The ScrollView can only have one child, typically a Linear Layout Viewgroups (ScrollView) ScrollView Linear Layout View View View View View

  35. Viewgroups (ScrollView)

  36. Anchoring Views

  37. A preferable alternate to anchoring is to create custom screens based on orientation • To support Landscape mode, create a new folder in the res folder named layout-land Custom Orientations Screens • Layouts contained in the layout folder defines the UI for portrait mode • Layouts contained in the layout-land folder defines the UI for landscape mode

  38. Custom Landscape UI

  39. Changing screen orientation destroys the Activity and re-creates it • Current state of the Activity is lost • When an Activity is killed, it’ll fire the onPause and onSaveInstanceState events • You can implement the onPause event to save state information to database, internal or external storage • Or • Implement the onSaveInstanceState event and save the state using Bundle object • After the activity is re-recreated retrieve and reset the state in the onRestoreInstanceState event Persisting State Information

  40. Persisting State Information • Flow: • Orientation Changes • Activity is Killed • Activity is re-created • State information “McBean” is lost

  41. These are the major events triggered during the life cycle of an Activity • Additionally • onRestoreInstanceState occurs after onStart • onSaveInstanceState occurs after onPause Activity Life cycle

  42. Persisting State Information

  43. Registering Events for Views • Views can fire events when user interacts with them • The appropriate events need to be explicitly registered • Events can be registered using an inner class or an anonymous class

  44. Using the AnchorView as an example • The buttons are linked to the UI buttons using findViewById • The setOnClickListener gives the buttons “ears” to listen for the click event to be triggered by the user • btn1…btn4 call an anonymous class btnListener • Btn5 calls an inner class Registering Events for Views

  45. 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 Basic Views

  46. The ListView displays a long list of items in an Activity • No UI Layout Required • Presentation is dictated by the second parameter of the setListAdapter Simple LIST View

  47. Colleges array was moved to strings.xml file and now called as a resource Custom LIST View

  48. Similar to the ListView except is used when other Views will be displayed on the UI Spinner View

More Related