Activities and Intents. Activities Activity is a window that contains the user interface of your application,typically an application has one or more.

Slides:



Advertisements
Similar presentations
Programming with Android: Activities
Advertisements

PROCESS MANAGEMENT Y. Colette LeMard.
Lecture 10 Sharing Resources. Basics of File Sharing The core component of any server is its ability to share files. In fact, the Server service in all.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
CNT 4603: Managing/Maintaining Server 2008 – Part 3 Page 1 Dr. Mark Llewellyn © CNT 4603: System Administration Spring 2014 Managing And Maintaining Windows.
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.
Android Life Cycle CS328 Dick Steflik. Life Cycle The steps that an application goes through from starting to finishing Slightly different than normal.
More on User Interface Android Applications. Layouts Linear Layout Relative Layout Table Layout Grid View Tab Layout List View.
Microsoft ® Office PowerPoint ® 2003 Training Playing movies [Your company name] presents:
1 CGS1060 Mobile UIs Copyright 2012 by Janson Industries.
Android Application Development 2013 PClassic Chris Murphy 1.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle.
Intro to Android Programming George Nychis Srinivasan Seshan.
CS5103 Software Engineering Lecture 08 Android Development II.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
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.
Android Info mostly based on Pro Android 3.  User Applications  Java Libraries – most of Java standard edition ◦ Activities/Services ◦ UI/Graphics/View.
CIS—100 Chapter 15—Windows Vista 1. Parts of a Window 2.
Copyright© Jeffrey Jongko, Ateneo de Manila University Of Activities, Intents and Applications.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
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.
DKU-MUST Mobile ICT Education Center 10. Activity and Intent.
Asking the USER for values to use in a software 1 Input.
Activities Димитър Н. Димитров Astea Solutions AD.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
System Restore BCIS 3680 & BCIS Better Safe than Sorry  Before installing programs used in this course (NetBeans, MySQL, etc.), it’s highly recommended.
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android.
Perfecto Mobile Automation
CHAPTER 6 Threads, Handlers, and Programmatic Movement.
System Software (1) The Operating System
Services. What is a Service? A Service is not a separate process. A Service is not a thread. A Service itself is actually very simple, providing two main.
Android Fragments. Slide 2 Lecture Overview Getting resources and configuration information Conceptualizing the Back Stack Introduction to fragments.
Mobile Application Development BSCS-7 Lecture # 2
Component 2 6G, H, I, J, K.
Activities, Fragments, and Events
Fragment ?.
Mobile Application Development BSCS-7 Lecture # 6
Activities and Intents
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.
The Android Activity Lifecycle
ANDROID UI – FRAGMENTS UNIT II.
CIS 470 Mobile App Development
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
CIS 470 Mobile App Development
Activity Lifecycle.
Activities and Intents
SE4S701 Mobile Application Development
Activities and Fragments
Activities, Fragments, and Intents
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Activities and Intents

Activities Activity is a window that contains the user interface of your application,typically an application has one or more activites,the main aim of the activity is to interact with the user,From the moment,the activity appears on the screen to the moment it is hidden,it goes through a number of stages known as a activity life cycle

Activity Manager is responsible for creating, destroying, and overall managing activities. For example, when the user starts an application for the first time, the activity manager will create its activity and put it onto the screen. Later, when the user switches screens, the activity manger will move that previous activity to a holding place. This way, if the user wants to go back to an older activity, it can be started more quickly. Older activities that user hasn’t used in a while will be destroyed in order to free more space for the currently active one. This mechanism is designed to help improve the speed of user interface and thus improve the overall user experience.

Starting state When an activity doesn’t exist in memory, it is in Starting State. While it’s starting up, the activity will go through a whole set of callback methods that you as a developer have an opportunity to fill out. Keep in mind that this transition from Starting State to Running State is one of the most expensive operations in terms of computing time needed. The computing time directly effects the battery life of the device as well. This is the exact reason why we don’t automatically destroy activities that are no longer shown. User may want to come back to them, so we keep them around for awhile

Running state Activity in a Running State is the one that is currently on the screen interacting with the user. We also say this activity is in focus, meaning that all user interactions, such as typing, touching screen, clicking buttons, are handled by this one activity. As such, there is only one running activity at any one time. The running activity is the one that has all the priorities in terms of getting memory and resources needed to run as fast as possible. This is because Android wants to make sure the running activity is zippy and responsive to user.

Paused state When an activity is not in focus (i.e. not interacting with the user) but still visible on the screen, we say it’s in Paused State. This is not a very typical scenario since the screen is usually small and an activity is either taking the whole screen or not at all. We often see this case with dialog boxes that come up in front an activity causing it to become Paused. Paused State is a state that all activities go through it en route to being stopped.Paused activities still have high priority in terms of getting memory and other resources. This is because they are visible and cannot be removed from the screen without making it look very strange to the use

Stopped state When an activity is not visible, but still in memory, we say it’s in Stopped State. Stopped activity could be brought back to front to become a Running activity again. Or, it could be destroyed and removed from memory.System keeps activities around in Stopped State because it is likely that the user will still want to get back to those activities some time soon. And restarting a stopped activity is far cheaper than starting an activity from scratch. That is because we already have all the objects loaded in memory and just simply have to bring it all up to foregroun Stopped activities can also, an any point, be removed from memory.

Destroyed state A destroyed activity is no longer in memory. The Activity Manager decided that this activity is no longer needed, and as such has removed it. Before the activity is destroyed, you, the developer, have an opportunity to perform certain actions, such as save any unsaved information. However, there’s no guarantee that your activity will be Stopped prior to being Destroyed. It is possible that a Paused activity gets destroyed as well. For that reason, it is better to do important work, such as saving unsaved data, en route to being Paused rather than Destroyed.

The fact that an activity is in Running State doesn’t mean it’s doing much. It could be just sitting there and waiting for user input. Similarly, an activity in Stopped State is not necessarily doing nothing. The state names mostly refer to how active the activity is with respect to user input. In other words, weather an activity is in visible, in focus, or not visible at all.

intents An intent is a glue that enables different activities from different applications to work together seamlessly ensuring that tasks can be performed as though they belong to one single application. Intents are messages that are sent among major building blocks. They trigger an activity to start up, a service to start or stop, or are simply broadcasts.

intents

Understanding the activity To create an cativity you create a java class that extends the activity base class,your activity class loads its UI comonents using the XML file defined in the res/layout folder; setContentView(R.layout.main)

Your each and every activity would be define into your AndroidManifest.xml file

Activity(continued) Activity base class defines a series of events that governs the lifecycle of an Activity, the activity class defines the following events. onCreate() — Called when the activity is first created onStart() — Called when the activity becomes visible to the user onResume() — Called when the activity starts interacting with the user onPause() — Called when the current activity is being paused and the previous activity is being resumed onStop() — Called when the activity is no longer visible to the user onDestroy() — Called before the activity is destroyed by the system (either manually or by the system to conserve memory) onRestart() — Called when the activity has been stopped and is restarting again

First I will show you Logcat, this is a nice and quick way to exchange information from the application on your device and the development computer. To use Logcat first import android.util.Log in your project. Now you can call the static class Log from your project to start logging. As you can see below, Logcat has different levels of logging. When debugging we’ll just use Debug (D) to log the progress. Of course when you want to log an actual error you will use Error (E). V — Verbose (lowest priority) D — Debug I — Info W — Warning E — Error F — Fatal S — Silent (highest priority, on which nothing is ever printed)

Applying styles and Themes to Activity

To Display the activity as a Dialog By default an activity occupys the entire screen,we can apply a dialog theme to an activity sothat so that it is displayed as a floating dialog,eg you can customize your activity to display as a popup,warning the user about the action the user is going to perform To apply a dialog theme to an activity, simply modify the element in the AndroidManifest.xml file by adding the android:theme attribute:

Charsequency[] String implements the CharSequence interface. CharSequence is implemented by String, but also CharBuffer, Segment, StringBuffer, StringBuilder. So a String[] and a CharSequence[] is essentially the same. But CharSequence is the abstraction, and String is the implementation. By the way, '[]' denotes an array of objects. So String[] is an array of strings. And String itself is an array of characters