Widgets & Fragments Kalin Kadiev Astea Solutions AD.

Slides:



Advertisements
Similar presentations
Programming with Android: Android for Tablets Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.
Advertisements

Programming with Android: Activities
Programming with Android: Android for Tablets Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
CSE2102 Introduction to Software Engineering Lab 2 Sept/4/2013.
Fragments: Introduction Fragments were introduced in Android 3.0 to support flexible and dynamic UI designs represent portions of an application’s user.
Programming with Android: Activities
Android 02: Activities David Meredith
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
The Android Activity Lifecycle. Slide 2 Introduction Working with the Android logging system Rotation and multiple layouts Understanding the Android activity.
The Activity Class 1.  One application component type  Provides a visual interface for a single screen  Typically supports one thing a user can do,
Android Fragments.
More on User Interface Android Applications. Layouts Linear Layout Relative Layout Table Layout Grid View Tab Layout List View.
Programming with Android: Android Fragments Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle.
Android: versions Note that: Honeycomb (Android v3.0) A tablet-only release Jelly Bean (Android v4.1) Released on July 09, 2012.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Android Mobile computing for the rest of us.* *Prepare to be sued by Apple.
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml.
Android – Fragments L. Grewe.
Cosc 4730 Android Fragments. Fragments You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own.
Noname. Conceptual Parts States of Activities Active Pause Stop Inactive.
Activities Димитър Н. Димитров Astea Solutions AD.
Class on Fragments & threads. Fragments fragment is a modular section of an activity, which has its own lifecycle, receives its own input events, and.
CHAPTER 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
Android Fragments. Slide 2 Lecture Overview Getting resources and configuration information Conceptualizing the Back Stack Introduction to fragments.
Building UI Components Димитър Н. Димитров Astea Solutions AD.
Android Application -Architecture.
Open Handset Alliance.
Mobile Application Development BSCS-7 Lecture # 2
Activity and Fragment.
Basic Activities and Intents
Activities, Fragments, and Events
Fragment ?.
Fragments: Introduction
Android 3: Fragments: API Guide
CS499 – Mobile Application Development
Mobile Application Development BSCS-7 Lecture # 6
Mobile Applications (Android Programming)
Activities and Intents
Android Activities An application can have one or more activities, where Each activity Represents a screen that an app present to its user Extends the.
Anatomy of an Android App and the App Lifecycle
Android Mobile Application Development
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Android 15: Fragments: API Guide
The Android Activity Lifecycle
Android – Fragments L. Grewe.
ANDROID UI – FRAGMENTS UNIT II.
CIS 470 Mobile App Development
Chapter 9: Fragments.
Anatomy of an Android App and the App Lifecycle
Activity Lifecycle Fall 2012 CS2302: Programming Principles.
Android Topics Android Activity Lifecycle and Experiment Toast
Activities and Intents
HNDIT2417 Mobile Application Development
Programming Mobile Applications with Android
CIS 470 Mobile App Development
Activity Lifecycle.
Activities and Intents
CIS 470 Mobile App Development
SE4S701 Mobile Application Development
Mobile Programming Dr. Mohsin Ali Memon.
Activities and Fragments
Android Development Tools
Korea Software HRD Center
Activities, Fragments, and Intents
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Widgets & Fragments Kalin Kadiev Astea Solutions AD

App widgets

App widgets Not just widgets, they are app widgets! Miniature, embeddable application views. Published by app widget providers, held by app widget hosts. Configured by app widget configuration activity.

App widget practices Update as infrequently as possible! Don't wake the device unless you really need it. Don't use more than 4x4 cells for your widget. NB: you can use a small subset of the available views. You can avoid waking the device while asleep by using AlarmManager. More info at http://developer.android.com/guide/topics/appwidgets/index.html#MetaData and http://developer.android.com/reference/android/app/AlarmManager.html

Remote Views Describes a view hierarchy that can be displayed in another process. Provides layout resource, that will be inflated Provides some basic operations for modifying the content of the inflated hierarchy.

Fragments A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity. Has its own lifecycle; Receives its own input events; Can be added or removed while the activity is running.

Fragments

Fragment Lifecycle fragment is added onAttach() onCreate() onCreateView() onResume() onStart() onActivityCreated() fragment is active Fragment is removed Fragment is added to the back stack, then removed Fragment is restored from the back stack 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). 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. onPause() onStop() onDestroyView() fragment is destroyed onDetach() onDestroy()

Coordinating lifecycles Each activity callback invokes a corresponding fragment callback; When the fragment is added to the activity, onAttach() is called; When the fragment is removed from the activity, onDetach() is called; When the activity's onCreate() returns, onActivityCreated() is called.

Managing fragments Two words: use FragmentManager Get existing fragments: findFragmentById() findFragmentByTag() Manage back stack: popBackStack() Manage fragments: use transactions Some words about fragment transactions: Create a new transaction via FragmentManager.beginTransaction() Create a new instance of your fragment Use FragmentTransaction.add/replace/remove (passing the fragment instance and the id of the container in the view hierarchy) Optionally, use FragmentTransaction.addToBackStack() Use FragmentTransaction.commit() Voila!

Fragments for all Why use fragments? What happened to TabActivity? Large screens handling More powerful than tab layouts. What happened to TabActivity? So, how to make tabs in 1.6-2.3.x? (96% of the current devices) Compatibility library!

Q&A + Feedback Questions? Feedback section: Did you hear well? Was there anything you didn’t understand? What would you like changed in our next lecture?

Recommended resources Fragments@developer.android.com Fragment documentation Fragments for All Application widgets App widget design guidelines RemoteViews