SlideShare a Scribd company logo
android activity
Activity
An Activity is an application component that provides a
screen with which users can interact in order to do
something, such as dial the phone, take a photo, send an
email, or view a map.
Each activity is given a window in which to draw its user
interface. The window typically fills the screen, but may
be smaller than the screen and float on top of other
windows.
Activity
An application usually consists of multiple activities that
are loosely bound to each other. Typically, one activity in
an application is specified as the "main" activity, which is
presented to the user when launching the application for
the first time. Each activity can then start another activity
in order to perform different actions.
Each time a new activity starts, the previous activity is
stopped, but the system preserves the activity in a stack .
When a new activity starts, it is pushed onto the back
stack and takes user focus.
Activity life cycle
Creating an Activity
To create an activity, you must create a subclass of
Activity (or an existing subclass of it). In your subclass,
you need to implement callback methods that the system
calls when the activity transitions between various states
of its lifecycle, such as when the activity is being created,
stopped, resumed, or destroyed. The two most important
callback methods are:
onCreate()
onPause()
Methods in Activity
onCreate() You must implement this method. The system
calls this when creating your activity. Within your
implementation, you should initialize the essential
components of your activity. Most importantly, this is
where you must call setContentView() to define the
layout for the activity's user interface.
onPause() The system calls this method as the first
indication that the user is leaving your activity (though it
does not always mean the activity is being destroyed).
This is usually where you should commit any changes that
should be persisted beyond the current user session .
There are several other lifecycle callback methods that
you should use in order to provide a fluid user experience
between activities and handle unexpected interuptions
that cause your activity to be stopped and even
destroyed. All of the lifecycle callback methods are
discussed later, in the section about Managing the
Activity Lifecycle.
onResume()
onStart()
onStop()
onDestroy()
onPause()
Other Methods
Sample Code
public class ExampleActivity extends Activity
{ Public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState); // The activity is being created.
}
Protected void onStart(){
super.onstart(); // The activity is about to become visible.
}
Protected void onPause(){
super.onPause(); // Another activity is taking focus (this activity is about to be
"paused"). }
Protected void onResume(){
super.onPause(); // The activity has become visible (it is now "resumed").
}
Protected void onstop(){
super.onPause(); // The activity is no longer visible (it is now "stopped")
}
Protected void onDestroy(){
super.onPause(); // The activity is about to be destroyed.
}
}
This is super class
For all classes
Declaring the activity in the manifest
You must declare your activity in the manifest file in
order for it to be accessible to the system. To
decalare your activity, open your manifest file and
add an <activity> element as a child of the
<application> element. For example:
<manifest ... >
<application ... >
<activity android: name=".ExampleActivity" />
...
</application ... >
...
</manifest >
Using intent filters
An <activity> element can also specify various intent
filters—using the <intent-filter> element—in order
to declare how other application components may
activate it.
• When you create a new application using the
Android SDK tools, the stub activity that's created
for you automatically includes an intent filter that
declares the activity responds to the "main" action
and should be placed in the "launcher" category.
The intent filter looks like this:
Using intent filters
<activity android:name=".ExampleActivity"
android:icon="@drawable/app_icon">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The <action> element
specifies that this is the
"main" entry point to the
application.
The <category> element specifies
that this activity should be listed in
the system's application launcher
(to allow users to launch this
activity).
Starting an Activity
You can start another activity by calling startActivity(),
passing it an Intent that describes the activity you
want to start. An intent can also carry small amounts
of data to be used by the activity that is started.
For example :
Intent intent = new Intent(this, Next. class);
intent.putExtra(“key”, value);
startActivity(intent);
Which is going
to be executed
Ad

More Related Content

What's hot (20)

Android activity
Android activityAndroid activity
Android activity
Krazy Koder
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
Ahsanul Karim
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
Sourabh Sahu
 
Android Components
Android ComponentsAndroid Components
Android Components
Aatul Palandurkar
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
Soham Patel
 
Activity lifecycle
Activity lifecycleActivity lifecycle
Activity lifecycle
Rehan Choudhary
 
Android Fragment
Android FragmentAndroid Fragment
Android Fragment
Kan-Han (John) Lu
 
Android activities & views
Android activities & viewsAndroid activities & views
Android activities & views
ma-polimi
 
Fragment
Fragment Fragment
Fragment
nationalmobileapps
 
android layouts
android layoutsandroid layouts
android layouts
Deepa Rani
 
Android Services
Android ServicesAndroid Services
Android Services
Ahsanul Karim
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferences
Ajay Panchal
 
Notification android
Notification androidNotification android
Notification android
ksheerod shri toshniwal
 
Mobile application development ppt
Mobile application development pptMobile application development ppt
Mobile application development ppt
tirupathinews
 
Fragments In Android
Fragments In AndroidFragments In Android
Fragments In Android
DivyaKS12
 
Android Intent.pptx
Android Intent.pptxAndroid Intent.pptx
Android Intent.pptx
vishal choudhary
 
Android UI
Android UIAndroid UI
Android UI
nationalmobileapps
 
Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
Vibrant Technologies & Computers
 
Android studio installation
Android studio installationAndroid studio installation
Android studio installation
PoojaBele1
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
Tareq Hasan
 

Similar to android activity (20)

Android application componenets for android app development
Android application componenets for android app developmentAndroid application componenets for android app development
Android application componenets for android app development
BalewKassie
 
Unit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptxUnit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptx
ShantanuDharekar
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3
Dr. Ramkumar Lakshminarayanan
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2
DHIRAJ PRAVIN
 
Android development session 2 - intent and activity
Android development   session 2 - intent and activityAndroid development   session 2 - intent and activity
Android development session 2 - intent and activity
Farabi Technology Middle East
 
Activity
ActivityActivity
Activity
NikithaNag
 
Activity
ActivityActivity
Activity
NikithaNag
 
Activity
ActivityActivity
Activity
roopa_slide
 
Activity
ActivityActivity
Activity
roopa_slide
 
android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last sem
aswinbiju1652
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MugiiiReee
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
Wingston
 
Android activity
Android activityAndroid activity
Android activity
Krazy Koder
 
Android Activities.pdf
Android Activities.pdfAndroid Activities.pdf
Android Activities.pdf
ssusere71a07
 
Mad textbook 63-116
Mad textbook 63-116Mad textbook 63-116
Mad textbook 63-116
PrathishGM
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
Jussi Pohjolainen
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
Dr. Chandrakant Divate
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
Kumar
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
Monir Zzaman
 
App Fundamentals and Activity life cycle.pptx
App Fundamentals and Activity life cycle.pptxApp Fundamentals and Activity life cycle.pptx
App Fundamentals and Activity life cycle.pptx
ridzah12
 
Android application componenets for android app development
Android application componenets for android app developmentAndroid application componenets for android app development
Android application componenets for android app development
BalewKassie
 
Unit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptxUnit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptx
ShantanuDharekar
 
Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3Android building blocks and application life cycle-chapter3
Android building blocks and application life cycle-chapter3
Dr. Ramkumar Lakshminarayanan
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2
DHIRAJ PRAVIN
 
android_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last semandroid_mod_3.useful for bca students for their last sem
android_mod_3.useful for bca students for their last sem
aswinbiju1652
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MugiiiReee
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
Wingston
 
Android activity
Android activityAndroid activity
Android activity
Krazy Koder
 
Android Activities.pdf
Android Activities.pdfAndroid Activities.pdf
Android Activities.pdf
ssusere71a07
 
Mad textbook 63-116
Mad textbook 63-116Mad textbook 63-116
Mad textbook 63-116
PrathishGM
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
Dr. Chandrakant Divate
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
Kumar
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
Monir Zzaman
 
App Fundamentals and Activity life cycle.pptx
App Fundamentals and Activity life cycle.pptxApp Fundamentals and Activity life cycle.pptx
App Fundamentals and Activity life cycle.pptx
ridzah12
 
Ad

More from Deepa Rani (20)

Speed controller of dc motor
Speed controller of dc motorSpeed controller of dc motor
Speed controller of dc motor
Deepa Rani
 
Foot step power generator
Foot step power generatorFoot step power generator
Foot step power generator
Deepa Rani
 
Crime investigation system
Crime investigation systemCrime investigation system
Crime investigation system
Deepa Rani
 
android content providers
android content providersandroid content providers
android content providers
Deepa Rani
 
android sqlite
android sqliteandroid sqlite
android sqlite
Deepa Rani
 
android menus
android menusandroid menus
android menus
Deepa Rani
 
android dilaogs
android dilaogsandroid dilaogs
android dilaogs
Deepa Rani
 
android architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution processandroid architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution process
Deepa Rani
 
Android the first app - hello world - copy
Android   the first app - hello world - copyAndroid   the first app - hello world - copy
Android the first app - hello world - copy
Deepa Rani
 
Android styles and themes
Android   styles and themesAndroid   styles and themes
Android styles and themes
Deepa Rani
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
Deepa Rani
 
Blue Brain
Blue BrainBlue Brain
Blue Brain
Deepa Rani
 
Tcp
TcpTcp
Tcp
Deepa Rani
 
Dc machiness
Dc machinessDc machiness
Dc machiness
Deepa Rani
 
Maddy android
Maddy androidMaddy android
Maddy android
Deepa Rani
 
Fabric innovation
Fabric innovationFabric innovation
Fabric innovation
Deepa Rani
 
Typical problem
Typical problemTypical problem
Typical problem
Deepa Rani
 
straight line
straight line straight line
straight line
Deepa Rani
 
Section of solids
Section of solidsSection of solids
Section of solids
Deepa Rani
 
Projection of solids
Projection of solidsProjection of solids
Projection of solids
Deepa Rani
 
Speed controller of dc motor
Speed controller of dc motorSpeed controller of dc motor
Speed controller of dc motor
Deepa Rani
 
Foot step power generator
Foot step power generatorFoot step power generator
Foot step power generator
Deepa Rani
 
Crime investigation system
Crime investigation systemCrime investigation system
Crime investigation system
Deepa Rani
 
android content providers
android content providersandroid content providers
android content providers
Deepa Rani
 
android sqlite
android sqliteandroid sqlite
android sqlite
Deepa Rani
 
android dilaogs
android dilaogsandroid dilaogs
android dilaogs
Deepa Rani
 
android architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution processandroid architecture,life cycle,sdk,execution process
android architecture,life cycle,sdk,execution process
Deepa Rani
 
Android the first app - hello world - copy
Android   the first app - hello world - copyAndroid   the first app - hello world - copy
Android the first app - hello world - copy
Deepa Rani
 
Android styles and themes
Android   styles and themesAndroid   styles and themes
Android styles and themes
Deepa Rani
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
Deepa Rani
 
Fabric innovation
Fabric innovationFabric innovation
Fabric innovation
Deepa Rani
 
Typical problem
Typical problemTypical problem
Typical problem
Deepa Rani
 
straight line
straight line straight line
straight line
Deepa Rani
 
Section of solids
Section of solidsSection of solids
Section of solids
Deepa Rani
 
Projection of solids
Projection of solidsProjection of solids
Projection of solids
Deepa Rani
 
Ad

Recently uploaded (20)

pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 

android activity

  • 2. Activity An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.
  • 3. Activity An application usually consists of multiple activities that are loosely bound to each other. Typically, one activity in an application is specified as the "main" activity, which is presented to the user when launching the application for the first time. Each activity can then start another activity in order to perform different actions. Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack . When a new activity starts, it is pushed onto the back stack and takes user focus.
  • 5. Creating an Activity To create an activity, you must create a subclass of Activity (or an existing subclass of it). In your subclass, you need to implement callback methods that the system calls when the activity transitions between various states of its lifecycle, such as when the activity is being created, stopped, resumed, or destroyed. The two most important callback methods are: onCreate() onPause()
  • 6. Methods in Activity onCreate() You must implement this method. The system calls this when creating your activity. Within your implementation, you should initialize the essential components of your activity. Most importantly, this is where you must call setContentView() to define the layout for the activity's user interface. onPause() The system calls this method as the first indication that the user is leaving your activity (though it does not always mean the activity is being destroyed). This is usually where you should commit any changes that should be persisted beyond the current user session .
  • 7. There are several other lifecycle callback methods that you should use in order to provide a fluid user experience between activities and handle unexpected interuptions that cause your activity to be stopped and even destroyed. All of the lifecycle callback methods are discussed later, in the section about Managing the Activity Lifecycle. onResume() onStart() onStop() onDestroy() onPause() Other Methods
  • 8. Sample Code public class ExampleActivity extends Activity { Public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); // The activity is being created. } Protected void onStart(){ super.onstart(); // The activity is about to become visible. } Protected void onPause(){ super.onPause(); // Another activity is taking focus (this activity is about to be "paused"). } Protected void onResume(){ super.onPause(); // The activity has become visible (it is now "resumed"). } Protected void onstop(){ super.onPause(); // The activity is no longer visible (it is now "stopped") } Protected void onDestroy(){ super.onPause(); // The activity is about to be destroyed. } } This is super class For all classes
  • 9. Declaring the activity in the manifest You must declare your activity in the manifest file in order for it to be accessible to the system. To decalare your activity, open your manifest file and add an <activity> element as a child of the <application> element. For example: <manifest ... > <application ... > <activity android: name=".ExampleActivity" /> ... </application ... > ... </manifest >
  • 10. Using intent filters An <activity> element can also specify various intent filters—using the <intent-filter> element—in order to declare how other application components may activate it. • When you create a new application using the Android SDK tools, the stub activity that's created for you automatically includes an intent filter that declares the activity responds to the "main" action and should be placed in the "launcher" category. The intent filter looks like this:
  • 11. Using intent filters <activity android:name=".ExampleActivity" android:icon="@drawable/app_icon"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> The <action> element specifies that this is the "main" entry point to the application. The <category> element specifies that this activity should be listed in the system's application launcher (to allow users to launch this activity).
  • 12. Starting an Activity You can start another activity by calling startActivity(), passing it an Intent that describes the activity you want to start. An intent can also carry small amounts of data to be used by the activity that is started. For example : Intent intent = new Intent(this, Next. class); intent.putExtra(“key”, value); startActivity(intent); Which is going to be executed