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

Size: px
Start display at page:

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

Transcription

1 FRAGMENTS

2 Fragments An activity is a container for views When you have a larger screen device than a phone like a tablet it can look too simple to use phone interface here. Fragments Mini-activities, each with its own set of views One or more fragments can be embedded in an Activity You can do this dynamically as a function of the device type (tablet or not) or orientation ALSO, you can reuse fragments --- like reuse of mini interfaces

3 Fragments

4 Fragments Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment The base class for all fragment definitions android.app.fragmentmanager The class for interacting with fragment objects inside an activity android.app.fragmenttransaction The class for performing an atomic set of fragment operations

5 FRAGMENTS A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities). A fragment must always be embedded in an activity.

6 Fragment Lifecycle Fragment in an Activity---Activity Lifecycle influences Activity paused all its fragments paused Activity destroyed all its fragments are destroyed Activity running manipulate each fragment independently. Fragment transaction add, remove, etc. adds it to a back stack that's managed by the activity each back stack entry in the activity is a record of the fragment transaction that occurred. The back stack allows the user to reverse a fragment transaction (navigate backwards), by pressing the Back button.

7 Fragment Lifecycle

8 Fragment Lifecycle Several callback methods to handle various stages of a Fragment lifecycle: oncreate() called when creating the Fragment. oncreateview() called when UI for the Fragment is drawn for the first time. onpause() called when the user is leaving the Fragment.

9 Fragment inside Activity It lives in a ViewGroup inside the activity's view hierarchy Fragment has its own view layout. Using Fragments via XML: Insert a fragment into your activity layout by declaring the fragment in the activity's layout file, as a <fragment> element, via CODE: from your application code by adding it to an existing ViewGroup. You may also use a fragment without its own UI as an invisible worker for the activity.

10 Fragment methods (callback functions) onattach(activity) called once the fragment is associated with its activity. oncreate(bundle) called to do initial creation of the fragment. oncreateview(layoutinflater, ViewGroup, Bundle) creates and returns the view hierarchy associated with the fragment. onactivitycreated(bundle) tells the fragment that its activity has completed its own Activity.onCreaate. onstart() makes the fragment visible to the user (based on its containing activity being started). onresume() makes the fragment interacting with the user (based on its containing activity being resumed).

11 Fragment methods (callback functions) As a fragment is no longer being used, it goes through a reverse series of callbacks: onpause() fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity. onstop() fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity. ondestroyview() allows the fragment to clean up resources associated with its View. ondestroy() called to do final cleanup of the fragment's state. ondetach() called immediately prior to the fragment no longer being associated with its activity.

12 Fragments and their UI Most fragments will have a UI You must implement the oncreateview() callback method, which the Android system calls when it's time for the fragment to draw its layout. Your implementation of this method must return a View that is the root of your fragment's layout.

13 FRAGMENT SUB CLASSES There are three subclasses of fragments: DialogFragment : Displays a floating dialog ListFragment : Displays a list of items that are managed by an adapter PreferenceFragment : Displays a hierarchy of Preference objects as a list

14 Fragment Application Using Eclipse, create a new Android project and name it Fragments. In the res/layout folder, add a new file and name it fragment1.xml. Populate it with the following: <?xml version= 1.0 encoding= utf-8?> <LinearLayout xmlns:android= android:orientation= vertical android:layout_width= fill_parent android:layout_height= fill_parent android:background= #00FF00 >

15 Fragment Application <TextView android:layout_width= fill_parent android:layout_height= wrap_content android:text= This is fragment #1 android:textcolor= # android:textsize= 25sp /> </LinearLayout>

16 Fragment Application Also in the res/layout folder, add another new file and name it fragment2.xml. Populate it as follows: <?xml version= 1.0 encoding= utf-8?> <LinearLayout xmlns:android= android:orientation= vertical android:layout_width= fill_parent android:layout_height= fill_parent android:background= #FFFE00 >

17 Fragment Application <TextView android:layout_width= fill_parent android:layout_height= wrap_content android:text= This is fragment #2 android:textcolor= # android:textsize= 25sp /> </LinearLayout>

18 Fragment Application In main.xml, add the following code. <?xml version= 1.0 encoding= utf-8?> <LinearLayout xmlns:android= android:layout_width= fill_parent android:layout_height= fill_parent android:orientation= horizontal > <fragment android:name= com.example.fragments.fragment1 android:layout_weight= 1 android:layout_width= 0px android:layout_height= match_parent />

19 Fragment Application <fragment android:name= com.example.fragments.fragment2 android:layout_weight= 1 android:layout_width= 0px android:layout_height= match_parent /> </LinearLayout>

20 Fragment Application Add two Java class files and name them Fragment1.java and Fragment2.java public class Fragment1 extends Fragment public View oncreateview(layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { } //---Inflate the layout for this fragment--- return inflater.inflate( R.layout.fragment1, container, false); }

21 Fragment Application public class Fragment2 extends Fragment public View oncreateview(layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { } } //---Inflate the layout for this fragment--- return inflater.inflate( R.layout.fragment2, container, false);

22 Fragment Application return inflater.inflate( R.layout.fragment1, container, false)

23 Fragment Application

24 How It Works A fragment behaves very much like an activity it has a Java class and it loads its UI from an XML file. The Java class for a fragment needs to extend the Fragment base class. To draw the UI for a fragment, you override the oncreateview() method. This method needs to return a View object. Use a LayoutInflater object to inflate the UI from the specified XML file. The container argument refers to the parent ViewGroup, which is the activity in which you are trying to embed the fragment. The savedinstancestate argument enables you to restore the fragment to its previously saved state. Note that each fragment needs a unique identifier. You can assign one via the android:id or android:tag attribute.

25 Adding Fragments Dynamically Fragments enable to compartmentalize UI into various configurable parts. The real power of fragments is realized when you add them dynamically to activities during runtime. It is much more useful to create fragments and add them to activities during runtime. This enables you to create a customizable user interface for your application. For example, if the application is running on a smartphone, you might fill an activity with a single fragment; if the application is running on a tablet, you might then fill the activity with two or more fragments, as the tablet has much more screen real estate compared to a smartphone.

26 Adding Fragments Dynamically Using the same project created in the previous section, modify the main.xml file by commenting out the two <fragment> elements: <!-- <fragment android:name= com.example.fragments.fragment1.. android:layout_height= match_parent /> <fragment android:name= com.example.fragments.fragment2 android:layout_height= match_parent /> -->

27 Adding Fragments Dynamically Add the following code in bold to the FragmentsActivity.java file. public class FragmentsActivity extends Activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); android.app.fragmentmanager fragmentmanager = getfragmentmanager(); FragmentTransaction fragmenttransaction = fragmentmanager.begintransaction(); WindowManager wm = getwindowmanager(); Display d = wm.getdefaultdisplay();

28 Adding Fragments Dynamically Point size = new Point(); d.getsize(size); int width = size.x; int height = size.y; if (width > height) { //---landscape mode--- Fragment1 fragment1 = new Fragment1(); // android.r.id.content refers to the content // view of the activity fragmenttransaction.replace(android.r.id.content, fragment1); }

29 Adding Fragments Dynamically else { //---portrait mode--- Fragment2 fragment2 = new Fragment2(); fragmenttransaction.replace(android.r.id.content, fragment2); } fragmenttransaction.commit(); } }

30 Adding Fragments Dynamically

31 THE END

UI Fragment.

UI Fragment. UI Fragment 1 Contents Fragments Overviews Lifecycle of Fragments Creating Fragments Fragment Manager and Transactions Adding Fragment to Activity Fragment-to-Fragment Communication Fragment SubClasses

More information

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time The 1 activity 1 thing the user can do heuristic may not make sense for larger devices Application

More information

FRAGMENTS.

FRAGMENTS. Fragments 69 FRAGMENTS In the previous section you learned what an activity is and how to use it. In a small-screen device (such as a smartphone), an activity typically fi lls the entire screen, displaying

More information

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

Multiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers Multiple devices Multiple devices Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers Create a new directory in your project's res/ and name it using the

More information

Mobile Computing Fragments

Mobile Computing Fragments Fragments APM@FEUP 1 Fragments (1) Activities are used to define a full screen interface and its functionality That s right for small screen devices (smartphones) In bigger devices we can have more interface

More information

Fragments and the Maps API

Fragments and the Maps API Fragments and the Maps API Alexander Nelson October 6, 2017 University of Arkansas - Department of Computer Science and Computer Engineering Fragments Fragments Fragment A behavior or a portion of a user

More information

ANDROID USER INTERFACE

ANDROID USER INTERFACE 1 ANDROID USER INTERFACE Views FUNDAMENTAL UI DESIGN Visual interface element (controls or widgets) ViewGroup Contains multiple widgets. Layouts inherit the ViewGroup class Activities Screen being displayed

More information

Programming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: Android for Tablets Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Android for Tablets: A Case Study Android for Tablets:

More information

Activities and Fragments

Activities and Fragments Activities and Fragments 21 November 2017 Lecture 5 21 Nov 2017 SE 435: Development in the Android Environment 1 Topics for Today Activities UI Design and handlers Fragments Source: developer.android.com

More information

Building User Interface for Android Mobile Applications II

Building User Interface for Android Mobile Applications II Building User Interface for Android Mobile Applications II Mobile App Development 1 MVC 2 MVC 1 MVC 2 MVC Android redraw View invalidate Controller tap, key pressed update Model MVC MVC in Android View

More information

Fragments. Lecture 11

Fragments. Lecture 11 Fragments Lecture 11 Situational layouts Your app can use different layouts in different situations Different device type (tablet vs. phone vs. watch) Different screen size Different orientation (portrait

More information

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING This document can be downloaded from www.chetanahegde.in with most recent updates. 1 MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING Syllabus: What is Android? Obtaining the required tools, Anatomy

More information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi Introduction An application is composed of at least one Activity GUI It is a software component that stays behind a GUI (screen) Activity It runs inside the

More information

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

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. User Interface Development CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. Rajiv Ramnath 1 Outline UI Support in Android Fragments 2 UI Support in the Android

More information

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

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie User Interface Design" & Development -

More information

Mobile Development Lecture 10: Fragments

Mobile Development Lecture 10: Fragments Mobile Development Lecture 10: Fragments Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Elgayyar.weebly.com Situational Layouts Your app can use different layout in different situations: different device type

More information

Fragments. Lecture 10

Fragments. Lecture 10 Fragments Lecture 10 Situa2onal layouts Your app can use different layouts in different situa2ons Different device type (tablet vs. phone vs. watch) Different screen size Different orienta2on (portrait

More information

Fragments. Fragments may only be used as part of an ac5vity and cannot be instan5ated as standalone applica5on elements.

Fragments. Fragments may only be used as part of an ac5vity and cannot be instan5ated as standalone applica5on elements. Fragments Fragments A fragment is a self- contained, modular sec5on of an applica5on s user interface and corresponding behavior that can be embedded within an ac5vity. Fragments can be assembled to create

More information

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

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml Android Application Written in Java (it s possible to write native code) Good

More information

Creating a User Interface

Creating a User Interface Creating a User Interface Developing for Android devices is a complicated process that requires precision to work with. Android runs on numerous devices from smart-phones to tablets. Instead of using a

More information

LECTURE NOTES OF APPLICATION ACTIVITIES

LECTURE NOTES OF APPLICATION ACTIVITIES Department of Information Networks The University of Babylon LECTURE NOTES OF APPLICATION ACTIVITIES By College of Information Technology, University of Babylon, Iraq Samaher@inet.uobabylon.edu.iq The

More information

Android User Interface

Android User Interface Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 20. Oktober 2014 Outline 1 Android User Interface 2 Multi-Language Support 3 Summary Matthias Keil Android

More information

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

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based

More information

UNDERSTANDING ACTIVITIES

UNDERSTANDING ACTIVITIES Activities Activity is a window that contains the user interface of your application. An Android activity is both a unit of user interaction - typically filling the whole screen of an Android mobile device

More information

EMBEDDED SYSTEMS PROGRAMMING UI and Android

EMBEDDED SYSTEMS PROGRAMMING UI and Android EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI and Android STANDARD GESTURES (1/2) UI classes inheriting from View allow to set listeners that respond to basic gestures. Listeners are defined by suitable interfaces.

More information

Android User Interface Android Smartphone Programming. Outline University of Freiburg

Android User Interface Android Smartphone Programming. Outline University of Freiburg Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 20. Oktober 2014 Outline 1 2 Multi-Language Support 3 Summary Matthias Keil 20. Oktober 2014 2 / 19 From

More information

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

CS371m - Mobile Computing. More UI Navigation, Fragments, and App / Action Bars CS371m - Mobile Computing More UI Navigation, Fragments, and App / Action Bars EFFECTIVE ANDROID NAVIGATION 2 Clicker Question Have you heard of the terms Back and Up in the context of Android Navigation?

More information

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

CS371m - Mobile Computing. More UI Action Bar, Navigation, and Fragments CS371m - Mobile Computing More UI Action Bar, Navigation, and Fragments ACTION BAR 2 Options Menu and Action Bar prior to Android 3.0 / API level 11 Android devices required a dedicated menu button Pressing

More information

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

A view is a widget that has an appearance on screen. A view derives from the base class android.view.view. LAYOUTS Views and ViewGroups An activity contains Views and ViewGroups. A view is a widget that has an appearance on screen. A view derives from the base class android.view.view. One or more views can

More information

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

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling Lecture 1 Review How to edit XML files in Android Studio? What holds all elements (Views) that appear to the user in an Activity?

More information

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming University of Babylon College of Information Technology Department of Information Networks Mobile Fundamentals and Programming Lecture 7: Data Persistence : shared preferences Lecturer : Ali Kadhim Al-Bermani

More information

Mobile User Interfaces

Mobile User Interfaces Mobile User Interfaces CS 2046 Mobile Application Development Fall 2010 Announcements Next class = Lab session: Upson B7 Office Hours (starting 10/25): Me: MW 1:15-2:15 PM, Upson 360 Jae (TA): F 11:00

More information

Overview of Activities

Overview of Activities d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems Programming

More information

States of Activities. Active Pause Stop Inactive

States of Activities. Active Pause Stop Inactive noname Conceptual Parts States of Activities Active Pause Stop Inactive Active state The state that the activity is on the most foreground and having a focus. This is in Active state. Active state The

More information

ANDROID APP DEVELOPMENT

ANDROID APP DEVELOPMENT 0 Version 1.2 ANDROID APP DEVELOPMENT By AbhiAndroid 0 AbhiAndroid.com 1 Awesome Thank you for downloading this guide Hi, My name is Abhishek. I m 26 year old guy from India. I m on mission and my mission

More information

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu Administrivia Moved back deadlines for projects 2, 3 and final project See updated schedule

More information

Activities. https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities

Activities. https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities Activities https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities Overview What is an Activity Starting and stopping activities The Back Stack

More information

Designing and Implementing Android UIs for Phones and Tablets

Designing and Implementing Android UIs for Phones and Tablets Designing and Implementing Android UIs for Phones and Tablets Matias Duarte Rich Fulcher Roman Nurik Adam Powell Christian Robertson #io2011 #Android 2 Ask questions Give feedback http://goo.gl/mod/zdyr

More information

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu Android UI Design Example GeoQuiz App Reference: Android Nerd Ranch, pgs 1 30 App presents

More information

EMBEDDED SYSTEMS PROGRAMMING Application Basics

EMBEDDED SYSTEMS PROGRAMMING Application Basics EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Basics APPLICATIONS Application components (e.g., UI elements) are objects instantiated from the platform s frameworks Applications are event driven ( there

More information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi View System A system for organizing GUI Screen = tree of views. View = rectangular shape on the screen that knows how to draw itself wrt to the containing

More information

Android Basics. Android UI Architecture. Android UI 1

Android Basics. Android UI Architecture. Android UI 1 Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à

More information

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu Android Activity LifeCycle Starting Activities Android applications don't start with a call to main(string[])

More information

Android Application Development

Android Application Development Android Application Development Octav Chipara What is Android A free, open source mobile platform A Linux-based, multiprocess, multithreaded OS Android is not a device or a product It s not even limited

More information

CHAPTER 4. Fragments ActionBar Menus

CHAPTER 4. Fragments ActionBar Menus CHAPTER 4 Fragments ActionBar Menus Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to configure the ActionBar Implement Fragments with Responsive

More information

This lecture. The BrowserIntent Example (cont d)

This lecture. The BrowserIntent Example (cont d) This lecture 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 10: Working with the Web Browser Dr Dimitris C. Dracopoulos Android provides a full-featured web browser based on the Chromium open source

More information

CS 4330/5390: Mobile Application Development Exam 1

CS 4330/5390: Mobile Application Development Exam 1 1 Spring 2017 (Thursday, March 9) Name: CS 4330/5390: Mobile Application Development Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and closed-book.

More information

Stanislav Rost CSAIL, MIT

Stanislav Rost CSAIL, MIT Session 2: Lifecycles, GUI Stanislav Rost CSAIL, MIT The Plan 1 Activity lifecycle Service lifecycle 2 Selected GUI elements UI Layouts 3 Hands on assignment: RoboChat Application GUI Design Birth, death,

More information

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

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2. Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code

More information

University of Babylon - College of IT SW Dep. - Android Assist. Lect. Wadhah R. Baiee Activities

University of Babylon - College of IT SW Dep. - Android Assist. Lect. Wadhah R. Baiee Activities Activities Ref: Wei-Meng Lee, BEGINNING ANDROID 4 APPLICATION DEVELOPMENT, Ch2, John Wiley & Sons, 2012 An application can have zero or more activities. Typically, applications have one or more activities;

More information

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

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu Announcements Group formation: Projects 2, 3 and final project will be

More information

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

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Application Components Hold the content of a message (E.g. convey a request for an activity to present an image) Lecture 2: Android Programming

More information

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

User Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University User Interface: Layout Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University http://twitter.com/krunapon Agenda User Interface Declaring Layout Common Layouts User Interface

More information

Mobile Application Development Android

Mobile Application Development Android 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

More information

Android UI: Overview

Android UI: Overview 1 Android UI: Overview An Activity is the front end component and it can contain screens. Android screens are composed of components or screen containers and components within the containers Screen containers

More information

ListView Containers. Resources. Creating a ListView

ListView Containers. Resources. Creating a ListView ListView Containers Resources https://developer.android.com/guide/topics/ui/layout/listview.html https://developer.android.com/reference/android/widget/listview.html Creating a ListView A ListView is a

More information

Lab 1: Getting Started With Android Programming

Lab 1: Getting Started With Android Programming Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Eng. Jehad Aldahdooh Mobile Computing Android Lab Lab 1: Getting Started With Android Programming To create a new Android Project

More information

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

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Android Lifecycle An activity begins its lifecycle when entering the oncreate() state If not

More information

Real-Time Embedded Systems

Real-Time Embedded Systems Real-Time Embedded Systems DT8025, Fall 2016 http://goo.gl/azfc9l Lecture 8 Masoumeh Taromirad m.taromirad@hh.se Center for Research on Embedded Systems School of Information Technology 1 / 51 Smart phones

More information

Embedded Systems Programming - PA8001

Embedded Systems Programming - PA8001 Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 8 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering

More information

CS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle

CS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle Application Components five primary components different purposes and different lifecycles Activity single screen with a user interface,

More information

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: System Architecture Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Android Architecture: An Overview Android Dalvik Java

More information

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH Android Basics - Bhaumik Shukla Android Application Developer @ STEALTH FLASH Introduction to Android Android is a software stack for mobile devices that includes an operating system, middleware and key

More information

More Effective Layouts

More Effective Layouts More Effective Layouts In past weeks, we've looked at ways to make more effective use of the presented display (e.g. elastic layouts, and separate layouts for portrait and landscape), as well as autogenerating

More information

Introduction To Android

Introduction To Android Introduction To Android Mobile Technologies Symbian OS ios BlackBerry OS Windows Android Introduction to Android Android is an operating system for mobile devices such as smart phones and tablet computers.

More information

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

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Entire Lifetime An activity begins its lifecycle when entering the oncreate() state If not interrupted

More information

CE881: Mobile & Social Application Programming

CE881: Mobile & Social Application Programming CE881: Mobile & Social Application Programming, s, s and s Jialin Liu Senior Research Officer Univerisity of Essex 6 Feb 2017 Recall of lecture 3 and lab 3 :) Please download Kahoot or open a bowser and

More information

Vienos veiklos būsena. Theory

Vienos veiklos būsena. Theory Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is

More information

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering Getting Started Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador 1 Goals Setting up your development environment Android Framework

More information

04. Learn the basic widget. DKU-MUST Mobile ICT Education Center

04. Learn the basic widget. DKU-MUST Mobile ICT Education Center 04. Learn the basic widget DKU-MUST Mobile ICT Education Center Goal Understanding of the View and Inheritance of View. Learn how to use the default widget. Learn basic programming of the Android App.

More information

Minds-on: Android. Session 2

Minds-on: Android. Session 2 Minds-on: Android Session 2 Paulo Baltarejo Sousa Instituto Superior de Engenharia do Porto 2016 Outline Activities UI Events Intents Practice Assignment 1 / 33 2 / 33 Activities Activity An activity provides

More information

(c) Dr Sonia Sail LAJMI College of Computer Sciences & IT (girl Section) 1

(c) Dr Sonia Sail LAJMI College of Computer Sciences & IT (girl Section) 1 Level 5: Baccalaureus in Computer Sciences CHAPTER 4: LAYOUTS AND VIEWS Dr. Sonia Saïd LAJMI PhD in Computer Sciences 1 Layout.xml 2 Computer Sciences & IT (girl Section) 1 Layout Requirements android:layout_width:

More information

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

Programming with Android: System Architecture. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: System Architecture Luca Bedogni Dipartimento di Scienze dell Informazione Università di Bologna Outline Android Architecture: An Overview Android Java Virtual Machine Android

More information

Programmatically Working with Android Fragments

Programmatically Working with Android Fragments Visit: www.intertech.com/blog Programmatically Working with Android Fragments Fragments (since Android ) can be used to organize the display of information in Activities, especially those that have to

More information

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game Tic-Tac-Toe 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game Dr Dimitris C. Dracopoulos O X X X O O X O X The Ultimate Tic-Tac-Toe: Rules of the Game Dimitris C. Dracopoulos

More information

Initialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III)

Initialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III) Dr Dimitris C. Dracopoulos Making a Move (GameFragment) Dimitris C. Dracopoulos 1/22 Initialising

More information

Repairing crashes in Android Apps. Shin Hwei Tan Zhen Dong Xiang Gao Abhik Roychoudhury National University of Singapore

Repairing crashes in Android Apps. Shin Hwei Tan Zhen Dong Xiang Gao Abhik Roychoudhury National University of Singapore Repairing crashes in Android Apps Shin Hwei Tan Zhen Dong Xiang Gao Abhik Roychoudhury National University of Singapore Android Repair System Criteria for Android repair system: Could be used by any smartphone

More information

CMSC436: Fall 2013 Week 3 Lab

CMSC436: Fall 2013 Week 3 Lab CMSC436: Fall 2013 Week 3 Lab Objectives: Familiarize yourself with the Activity class, the Activity lifecycle, and the Android reconfiguration process. Create and monitor a simple application to observe

More information

Using Eclipse for Android Development

Using Eclipse for Android Development 3 Using Eclipse for Android Development This chapter is an introduction to building a complete Android app. The chapter includes creating a new app project, exploring the components of an Android app,

More information

Gauthier Picard. Ecole Nationale Supérieure des Mines

Gauthier Picard. Ecole Nationale Supérieure des Mines Android Programming Gauthier Picard Ecole Nationale Supérieure des Mines 2013 This presentation is based on Jean-Paul Jamont s one (Université Pierre Mendès France, IUT de Valence) Android Programming

More information

Android Programming: More User Interface. CS 3: Computer Programming in Java

Android Programming: More User Interface. CS 3: Computer Programming in Java Android Programming: More User Interface CS 3: Computer Programming in Java Objectives Look at implementation of the UI from our tip calculator example Discuss dialogs Find out about fragments Revisiting

More information

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 Comment and Evaluation: This lab introduces us about Android SDK and how to write a program for Android platform. The calculator is pretty easy, everything

More information

Android Fundamentals - Part 1

Android Fundamentals - Part 1 Android Fundamentals - Part 1 Alexander Nelson September 1, 2017 University of Arkansas - Department of Computer Science and Computer Engineering Reminders Projects Project 1 due Wednesday, September 13th

More information

Lifecycle-Aware Components Live Data ViewModel Room Library

Lifecycle-Aware Components Live Data ViewModel Room Library Lifecycle-Aware Components Live Data ViewModel Room Library Multiple entry points launched individually Components started in many different orders Android kills components on reconfiguration / low memory

More information

The drawable/tile empty.xml file

The drawable/tile empty.xml file The X and O Symbols 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 3: Ultimate Tic-Tac-Toe Game: The Interface Dr Dimitris C. Dracopoulos Create them with the filenames x blue.png and o red.png in an

More information

CS 234/334 Lab 1: Android Jump Start

CS 234/334 Lab 1: Android Jump Start CS 234/334 Lab 1: Android Jump Start Distributed: January 7, 2014 Due: Friday, January 10 or Monday, January 13 (in-person check off in Mobile Lab, Ry 167). No late assignments. Introduction The goal of

More information

Lab 3. Accessing GSM Functions on an Android Smartphone

Lab 3. Accessing GSM Functions on an Android Smartphone Lab 3 Accessing GSM Functions on an Android Smartphone 1 Lab Overview 1.1 Goals The objective of this practical exercise is to create an application for a smartphone with the Android mobile operating system,

More information

Introductory Android Development

Introductory Android Development Introductory Android Development 152-163 Notes Quick Links & Text References Introduction Pages Layout Concepts Pages Layout Types Pages 35 37 XML Overview Pages Common Attributes Layout Height & Width

More information

14.1 Overview of Android

14.1 Overview of Android 14.1 Overview of Android - Blackberry smart phone appeared in 2003 First widely used mobile access to the Web - Smart phone market now dominated by Android, iphone, and Windows Phone - Tablets are now

More information

MC Android Programming

MC Android Programming MC1921 - Android Programming Duration: 5 days Course Price: $3,395 Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse

More information

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

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters Mobile Programming Lecture 5 Composite Views, Activities, Intents and Filters Lecture 4 Review How do you get the value of a string in the strings.xml file? What are the steps to populate a Spinner or

More information

COSC 3P97 Mobile Computing

COSC 3P97 Mobile Computing COSC 3P97 Mobile Computing Mobile Computing 1.1 COSC 3P97 Prerequisites COSC 2P13, 3P32 Staff instructor: Me! teaching assistant: Steve Tkachuk Lectures (MCD205) Web COSC: http://www.cosc.brocku.ca/ COSC

More information

CS378 -Mobile Computing. User Interface Basics

CS378 -Mobile Computing. User Interface Basics CS378 -Mobile Computing User Interface Basics User Interface Elements View Control ViewGroup Layout Widget (Compound Control) Many pre built Views Button, CheckBox, RadioButton TextView, EditText, ListView

More information

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna Programming with Android: System Architecture Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Android Architecture: An Overview Android Dalvik Java

More information

Android UI DateBasics

Android UI DateBasics Android UI DateBasics Why split the UI and programing tasks for a Android AP The most convenient and maintainable way to design application user interfaces is by creating XML layout resources. This method

More information

Lifecycle Callbacks and Intents

Lifecycle Callbacks and Intents SE 435: Development in the Android Environment Recitations 2 3 Semester 1 5779 4 Dec - 11 Dec 2018 Lifecycle Callbacks and Intents In this recitation we ll prepare a mockup tool which demonstrates the

More information

Lecture 2 Android SDK

Lecture 2 Android SDK Lecture 2 Android SDK This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a

More information

Android Programming (5 Days)

Android Programming (5 Days) www.peaklearningllc.com Android Programming (5 Days) Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse tools. This Android

More information

Android Activities. Akhilesh Tyagi

Android Activities. Akhilesh Tyagi Android Activities Akhilesh Tyagi Apps, memory, and storage storage: Your device has apps and files installed andstoredonitsinternaldisk,sdcard,etc. Settings Storage memory: Some subset of apps might be

More information

Have a development environment in 256 or 255 Be familiar with the application lifecycle

Have a development environment in 256 or 255 Be familiar with the application lifecycle Upcoming Assignments Readings: Chapter 4 by today Horizontal Prototype due Friday, January 22 Quiz 2 today at 2:40pm Lab Quiz next Friday during lecture time (2:10-3pm) Have a development environment in

More information