The document explains the concept of an Activity in Android applications, detailing its creation and navigation between multiple activities. It outlines the steps for creating an activity, the Android activity lifecycle, and the use of intents for navigating between activities. Additionally, it describes the key states of an activity and their corresponding callback methods.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views26 pages
Activity
The document explains the concept of an Activity in Android applications, detailing its creation and navigation between multiple activities. It outlines the steps for creating an activity, the Android activity lifecycle, and the use of intents for navigating between activities. Additionally, it describes the key states of an activity and their corresponding callback methods.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26
Activity
It represents a single screen or window of an application.
It is a specific combination of XML and Java File Everything we see and interact in an application is part of an activity, we can create multiple activities and navigate among them. Steps for Creating an activity • Go to java folder . • Right click on package file and select new. • Then select activity and from the gallery menu select template you want. • Give name, package name on thee activity and source language. • Whenever any activity is created it will generate 2 code file. • Activity.java file • Activity.xml file Navigation Between 2 activities • Create the New activity and Prepare its UI. • Add a Button or any view component to the first activity in XML file. • Create the touch listener in java file of first activity for navigating to the second Activity. Activity Stack Activity Life Cycle • The Android activity lifecycle describes the various states an activity goes through from its creation to its destruction, including when it's visible, hidden, or running in the background. This lifecycle is managed by the Android runtime system. • Here's a breakdown of the key states and their corresponding callback methods: • 1. onCreate(): This is the first method called when the activity is created. • 2. onStart(): Called when the activity becomes visible to the user. • 3. onResume(): This method is called when the activity starts interacting with the user • onPause(): Called when the activity is about to go into the background • onStop(): Called when the activity is no longer visible to the user. • onRestart(): Called after the activity has been stopped and is about to be restarted. • onDestroy(): The final call the activity receives before being destroyed. INTENT • Intents , in general, are used for navigating among various activities within the same application, but note, is not limited to one single application, i.e., they can be utilized from moving from one application to another as well. • There are two types of intents. • Explicit Intent. • Implicit Intent.