Mobile Application Development Android

Similar documents
Activities and Fragments

Android Application Development 101. Jason Chen Google I/O 2008

MC Android Programming

Android Programming (5 Days)

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

Android Programming Lecture 2 9/7/2011

Android User Interface Android Smartphone Programming. Outline University of Freiburg

Building User Interface for Android Mobile Applications II

Android User Interface

Praktikum Entwicklung Mediensysteme. Implementing a User Interface

Programming with Android: Intents. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: Activities and Intents. Dipartimento di Informatica Scienza e Ingegneria Università di Bologna

ANDROID APPS DEVELOPMENT FOR MOBILE GAME

Android Application Development

Using Intents to Launch Activities

Beginning Android 4 Application Development

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu

Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

Questions and Answers. Q.1) Which of the following is the most ^aeuroeresource hungry ^aeuroepart of dealing with activities on android?

Multiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers

Mobile and Ubiquitous Computing: Android Programming (part 3)

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)

CS378 -Mobile Computing. User Interface Basics

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Android Basics. Android UI Architecture. Android UI 1

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University

Mobile Application Development Android

The Intent Class Starting Activities with Intents. Explicit Activation Implicit Activation via Intent resolution

Android UI: Overview

LECTURE 08 UI AND EVENT HANDLING

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial

Android UI Development

Intents. 18 December 2018 Lecture Dec 2018 SE 435: Development in the Android Environment 1

Mobile User Interfaces

Programming Android UI. J. Serrat Software Design December 2017

Mobile Application Development Android

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Required Core Java for Android application development

The Intent Class Starting Activities with Intents. Explicit Activation Implicit Activation via Intent resolution

User Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University

ANDROID USER INTERFACE

EMBEDDED SYSTEMS PROGRAMMING UI and Android

M.C.A. Semester V Subject: - Mobile Computing (650003) Week : 2

05. RecyclerView and Styles

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

Mobile Application Development Android

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Creating a User Interface

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

CS371m - Mobile Computing. User Interface Basics

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners

The World of Android Development

Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna

06. Advanced Widget. DKU-MUST Mobile ICT Education Center

stolen from Intents and Intent Filters

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Software Practice 3 Today s lecture Today s Task Porting Android App. in real device

CS371m - Mobile Computing. More UI Action Bar, Navigation, and Fragments

MARS AREA SCHOOL DISTRICT Curriculum TECHNOLOGY EDUCATION

Practical Problem: Create an Android app that having following layouts.

A view is a widget that has an appearance on screen. A view derives from the base class android.view.view.

CS 4330/5390: Mobile Application Development Exam 1

CS371m - Mobile Computing. More UI Navigation, Fragments, and App / Action Bars

INTENTS android.content.intent

Lecture 2 Android SDK

Comparative Study on Layout and Drawable Resource Behavior in Android for Supporting Multi Screen

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

Android System Architecture. Android Application Fundamentals. Applications in Android. Apps in the Android OS. Program Model 8/31/2015

CMSC436: Fall 2013 Week 4 Lab

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are:

Pro Android 2. Sayed Y. Hashimi Satya Komatineni Dave Mac Lean. Apress

Java Training Center - Android Application Development

Mobile Computing Practice # 2c Android Applications - Interface

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based.

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

Designing and Implementing Android UIs for Phones and Tablets

Intents and Intent Filters

Outline. Admin. Example: TipCalc. Android: Event Handler Blocking, Android Inter-Thread, Process Communications. Recap: Android UI App Basic Concepts

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Our First Android Application

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

Mobile Application Development - Android

Android UI DateBasics

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

Stanislav Rost CSAIL, MIT

INTRODUCTION TO ANDROID

Minds-on: Android. Session 2

UI Fragment.

GUI Design for Android Applications

Sizing and Positioning

Course Learning Outcomes (CLO): Student Outcomes (SO):

Transcription:

Mobile Application Development Android Lecture 2 MTAT.03.262 Satish Srirama satish.srirama@ut.ee

Android Lecture 1 -recap What is Android How to develop Android applications Run & debug the applications Using resources and discussed the advantages of structured resources Android application lifecycle 9/9/2016 Satish Srirama 2/33

Outline Views and Layouts Events Basic application components 9/9/2016 Satish Srirama 3/33

Views Views are the building blocks The user interface is built using Viewand ViewGroup objects Examples: Can be as basic as: TextView, EditText, ListView Fancier views: ImageView, MapView, WebView http://developer.android.com/resources/tutorials/views/index.html 9/9/2016 Satish Srirama 4/33

SimpleViewItems TextView EditText Can also be used as a password field Button CheckBox RadioButton Spinner 9/9/2016 Satish Srirama 5/33

More View Items ListView(ViewGroup) WebView MapView 9/9/2016 Satish Srirama 6/33

Source: unlocking android, p 71 9/9/2016 Satish Srirama 7/33

View Hierarchy Activity's UI will be defined by a hierarchy of View and ViewGroup nodes ViewGroup objects are invisible view containers 9/9/2016 Satish Srirama 8/33

Layouts Layouts are ViewGroupswhich are used to hold other Views They are Invisible Allow positioning of different elements Layouts can be nested inside of each other 9/9/2016 Satish Srirama 9/33

Layouts LinearLayout: single row or column RelativeLayout : relative to other Views FrameLayout: each child a layer TableLayout: rows and columns AbsoluteLayout: <x,y> coordinates - Deprecated 9/9/2016 Satish Srirama 10/33

Linear Layout Vertical: Makes one column of views Horizontal: Makes one row of views When a View (such as a Button) is added to a Layout, parameters can be set on how that View is considered within the Layout FILL_PARENT: Expand the View as much as possible to fill the space of the parent container (Layout) Renamed to MATCH_PARENT in API Level 8 and higher WRAP_CONTENT: Make the view be just large enough to hold its contents Can apply to both width and height of View LAYOUT_WEIGHT: A weighting indicating relative sizes of multiple Views when sharing a layout 9/9/2016 Satish Srirama 11/33

Linear Layout -Example 9/9/2016 Satish Srirama 12/33

Exercise: Layouts Work with Linear Layout Design Estonian and Italian national flags one after the other https://developer.android.com/guide/topics/ui/layout/linear.html 9/9/2016 Satish Srirama 13/33

RelativeLayout A Layout where the location for added Views can be described: Relative to other Views added ( to the left of X ) Relative to the RelativeLayoutcontainer ( aligned to the container bottom ) Very flexible Suggested for use over nested LinearLayouts More complex the nesting of a layout, the longer to inflate 9/9/2016 Satish Srirama 14/33

RelativeLayout-Example 9/9/2016 Satish Srirama 15/33

Input Events What are views without having support for user interactions!!! Define an event listener and register it with the View mybutton.setonclicklistener(new View.OnClickListener() {}); Override an existing callback method for the View @Override public void onclick(view v) http://developer.android.com/guide/topics/ui/ui-events.html 9/9/2016 Satish Srirama 16/33

Input Events-continued Alternatively one can add the android:onclickattribute to the <Button> element. Then define the sendmessage method in MainActivity 9/9/2016 Satish Srirama 17/33

Exercise: Input events Demo: How to use buttons Work with Relative Layout C to F converter 9/9/2016 Satish Srirama 18/33

Other interesting UI elements Action Bar A dedicated space for giving your app an identity and indicating the user's location in the app Access to important actions in a predictable way (such as Search) Support for navigation and view switching (with tabs or dropdown lists) Beginning from Android 3.0 (API level 11), the action bar is included in all activities that use the Theme.Holo(default) theme By default it contains -app icon and activity title http://developer.android.com/training/basics/actionbar/index.html 9/9/2016 Satish Srirama 19/33

Options menu and action bar Primary collection of menu items for an activity Place actions that have a global impact on the app such as "Search," "Compose email," and "Settings." On-screen action items and overflow options To define the menu, create an XML file inside your project's res/menu/ directory 9/9/2016 Satish Srirama 20/33

Other interesting UI elements - continued Fragments You can build dynamic UI multi-pane user interface To create a fragment, extend the Fragment class Add the fragment to the activity layout using xml <fragment android:name= ee.ut.cs.mc.and.articlefragment" android:id="@+id/article_fragment android:layout_weight="2" android:layout_width="0dp" android:layout_height="match_parent" /> public class MainActivity extends FragmentActivity{ 9/9/2016 Satish Srirama 21/33 http://developer.android.com/training/basics/fragments/index.html

Basic Application Components Application components are the essential building blocks of an Android application Activities UI component Typically corresponding to one screen. BroadcastReceivers Respond to broadcast Intents Services Faceless tasks that run in the background ContentProviders Enable applications to share data 9/9/2016 Satish Srirama 22/33

Activities Typically correspond to one screen in a UI But, they can: be faceless be in a floating window return a value For more info https://developer.android.com/guide/compon ents/activities.html 9/9/2016 Satish Srirama 23/33

Intents Unique concept in Android Mobile applications mostly run in their sandboxes Applications are isolated from each other Intents support interactions among the application components Components can be of any application in the device Android does not distinguish third party applications and native applications Activities, services, and broadcast receivers are all activated through Intent messages 9/9/2016 Satish Srirama 24/33

Working with Intents Declare your intention that an Activity or Service be started to perform an action Broadcast that an event/action has occurred System matches Intent with Activity that can best provide that service Activities and BroadcastReceiversdescribe what Intents they can service in their IntentFilters(via AndroidManifest.xml) 9/9/2016 Satish Srirama 25/33

Using intents to launch activities Explicitly starting new Activities Intent intent = new Intent(this, MyOtherActivity.class); startactivity(intent); The new activity is started and no connection with the current activity Demo GreetingActivity (as part of course exercise) 9/9/2016 Satish Srirama 26/33

Intent Object An Intent object is a bundle of information Component name The name of the component that should handle the intent Information of interest to the component that receives the intent action The general action to be performed ACTION_CALL- Initiate a phone call ACTION_BATTERY_LOW- A warning that the battery is low Data The URI of the data to be acted on Uri uri = Uri.parse( content://contact/people ); http://developer.android.com/reference/android/content/intent.html 9/9/2016 Satish Srirama 27/33

Examplesofaction/datapairs ACTION_VIEW content://contacts/people/1 Display information about the person with identifier "1" ACTION_DIAL content://contacts/people/1 Display the phone dialer with the person filled in ACTION_VIEW tel:123 Display the phone dialer with the given number filled in VIEW action does what is considered the most reasonable thing for a particular URI ACTION_EDIT content://contacts/people/1 Edit information about the person whose identifier is "1" http://developer.android.com/guide/components/intents-common.html 9/9/2016 Satish Srirama 28/33

Intent Object -continued category Information of interest to the Android system Category of component that should handle the intent CATEGORY_BROWSABLE -The target activity can safely be invoked by the browser CATEGORY_LAUNCHER-it should appear in the Launcher as a top-level application ACTION_MAIN with category CATEGORY_HOME Launch the home screen. 9/9/2016 Satish Srirama 29/33

Intent Object -continued extras A Bundle of any additional information can be used to provide extended information to the component Example: if we have a action to send an e-mail message, we could also include extra pieces of data here to supply a subject, body, etc. Intent intent = new Intent(Intent.ACTION_SEND); intent.settype("plain/text"); intent.putextra(intent.extra_email, emailaddresslist); intent.putextra(intent.extra_subject, emailsubject); intent.putextra(intent.extra_text, emailtext); startactivity(intent); 9/9/2016 Satish Srirama 30/33

Implicit intents and late runtime binding The implicit Intents are mentioned in the Android Manifest file 9/9/2016 Satish Srirama 31/33

Intent resolution in Android Android puts together a list of Intent Filters Input Filters that do not match the action or category are removed from the list Each part of the Intent s data URI is compared to the Intent Filters data tag If more than one component is resolved, they are offered to the user to select 9/9/2016 Satish Srirama 32/33

Using intents to launch activities - continued To get the response back from the sub-activity private static final int SHOW_SUBACTIVITY = 1; StartActivityForResult(intent, SHOW_SUBACTIVITY); The response is sent back as setresult(activity.result_ok, resultintent); 9/9/2016 Satish Srirama 33/33

Homework Starting to use email Create an intent to send mail from GreetingActivity The list of ids you can put dynamically (I mean in the email screen itself in tofield) Put all the necessary info Then send the result back that the email is sent to the main activity Display in main activity email is sent For further description check the course page 9/9/2016 Satish Srirama 34/33

THANK YOU 9/9/2016 Satish Srirama 35