1 / 19

Class Business

Explore the history, issues, environment, user interface, and development in Android, an OS for smartphones, tablets, cars, watches, and cameras. Learn about activity, XML, Manifest files, and best practices in Android programming.

adrianaj
Download Presentation

Class Business

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. Class Business

  2. Android Introduction • Android is an operating system that runs on mobile platforms • “smartphones” & tablets • Cars • Watches • Cameras • Based on Linux • Open source, free

  3. History • Android, Inc founded in 2003, financed by Google • Google bought the company in 2005 • Android release Android in 2007 • First handset in 2008 • Releases are named after desserts/snacks(current is “Marshmallow” – Android 6.0.1)

  4. Issues on Android Platforms • Platforms are battery powered, restricted in CPU and memory • Screens are small compared to desktops • Policies • When an app is no longer in use, the system will suspend it in memory (consume no resources) • When memory is low, the system will kill apps and processes that have been inactive for a while

  5. Environment • Android Development Kit is free • Hooks into Eclipse or Android Studio • Emulators are useful

  6. User Interface • The UI for an Android app is built using a hierarchy of View and ViewGroup objects.  • View objects are usually UI widgets such as buttons or textfields  • ViewGroup objects are invisible view containers that define how the child views are laid out, such as in a grid or a vertical list.

  7. Assumed Methods • Android programming is very object oriented • There are lots of assumed methods initially defined as empty that govern app behavior.

  8. Activity • An Activity is the main object in an Android app. • Lifecycle:

  9. Example

  10. XML • HTML-like syntax that is used for many things, especially specification languages • HTML is actually a specialized XML • Tag-based language<blah> … </blah>

  11. Example: activity_main <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> </RelativeLayout>

  12. AndroidManifest.xml • Basic app specification file • Contains info on: • Permissions • Version minimums • Icons

  13. Example: Walk through Eclipse

  14. Event Programming in Android • Same idea, different methods, clunky implementation • Might want to take special actions to make the code look nice

  15. Listeners • OnClickListener is the analog to ActionListener in Java • Others: • OnLongClickListener • KeyListener • Many built-in listeners just need methods defined

  16. Example (note pattern) LinearLayout container = (LinearLayout) dialog.findViewById(R.id.new_class_dialog_button_container); EditText et = (EditText) dialog.findViewById(R.id.new_class_name); et.setText(""); et = (EditText) dialog.findViewById(R.id.new_class_nickname); et.setText(""); Button button = (Button) container.findViewById(R.id.create_new_button); button.setOnClickListener(new createNewClassDialogAction(dialog)); button = (Button) container.findViewById(R.id.cancel_new_button); button.setOnClickListener(new cancelDialogAction(dialog));

  17. Stupid: showDialog • When a dialog needs to be display, you would call “showDialog(DIALOGNUMBER)” • Then define “onCreateDialog(int dialognum)” • Amounts to a big if…then…else… combinationReally bad code

  18. Exercise

  19. Look at complex example

More Related