SlideShare a Scribd company logo
Welcome

Every Day is a new Beginning
Major Application components
Any Android application must have at least one amongst the following
components:
•

Activity

•

Intent & Intent Filters

•

Broadcast Receivers

•

Services

•

Content Providers
Activity
•Activity is an application component which provides User Interface(UI) to any
application

•An application can have any number of activities but only one of them can have the
focus at any given time of the application’s visible lifetime
•All other activities are moved to a “back-stack” which uses First In First Out (FIFO)
mechanism to handle those activities
•All activities have a set of methods known as “Callback methods”, which will get
triggered during different stages of an Activity lifecycle
•Views control rectangular space within an activity & interacts with the user

•Widgets = Views + Visual elements + business logic
•Layouts are special type of Views, which are derived from ViewGroup group
Activity Lifecycle
Activity – Callback methods
• onCreate() – triggered when the Activity is created

• onStart() – triggered when the Activity is started
• onResume() – triggered when the Activity is resumed after pause
• onPause() – triggered when the Activity is paused
• onStop() – triggered when the Activity goes out to background stack
• onDestroy() – triggered when the Activity is destroyed
States of an Activity

An activity can be in anyone of the states in its entire lifecycle:
• Resumed – Activity is in running
• Paused – Activity is paused & visible in the background
• Stopped – Activity is paused & not visible in the background ( in backstack)
Start & Stop an Activity
• An activity can be started in two ways :
•
•

Using startActivity(Intent intent) method
Using startActivityForResult(int reqCode,int resCode, Intent data) method

• The first method is used to start an activity normally
• The second method is used to start an activity when a specific resultant
action is expected. Eg. Choose a phone contact from Contacts application
• If an activity is started using second method, the control will be passed to
this method after the expected result – onActivityResult()
• An activity can be stopped/killed in ways:
•
•

Using finishActivity() method (Recommended)
Using finish() method
How to start an Activity
• An activity can be started from another activity using another application
component called Intent.
• A java class with name Sample.java, which extends Activity class must be
created.
• An entry in AndroidManifest.xml file should be included
• A layout XML file must be created and proper layout should be created in
XML file
• Code snipped to start an activity (using its name):
Intent intent = new Intent(this, Sample.class);
startActivity(intent);
How to start an Activity
• An activity can also be started without explicitly stating its name but the
action that it can perform
Steps:
• A java class with name Sample.java, which extends Activity class must be
created.
• An entry in AndroidManifest.xml file is included & an action is defined in
Intent_Filter tag
• A layout XML file is created and proper layout is created in XML file
• Code snipped to start an activity (using its name):
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, recipientArray);
startActivity(intent);
Intents
•

Application components are activated through messages called Intents

•

Intents provide a facility for late runtime binding between components of
same application or different applications as well

•

Basically, it is a passive data structure, which holds an abstract definition of an
action performed or to be taken

•

It is used to start Activities using “startActivity(intent)” method

•

It is also used to start or bind Services using “startService(intent)” and
“bindService(intent)” methods

•

It is also used to send broadcasts using “sendStickyBroadcast(intent)” methods
Intent Objects
Every Intent contains at least one of the following objects:
1.

Component Name [optional] – Component with Intent is associated

2.

Action (mandatory)

3.

Category (mandatory at least once) – Category of Action

4.

Data [optional & depends on type of Action] – URI & MIME type of data
needed to complete Action

5.

Extras [optional] – Data needed to complete Action

6.

Flags [optional] – Eg. Which task the activity should belong to ?
Intent Types
Intents can be classified into following two types:
•

Explicit Intents – Associated component name is explicitly mentioned
Intent intent1 = new Intent(this,ActivityTwo.class);
startActivity(intent);

•

Implicit Intents – Associated component name is implied (not mentioned)
Intent intent = new Intent(Intent.ACTION_SEND);

intent.putExtra(Intent.EXTRA_EMAIL, recipientArray);
startActivity(intent);
Intent Types & Resolution
Intent Resolution :
• Intents are resolved after undergoing three tests by Intent Filter
• Intent Filter filters the suitable components based on the expected action
and other input data

1.
2.
3.

Intent Filter performs the tests in the following order and finally resolves
the component(s) associated with the Intent
Action Test
Data Test
Category Test

• Those components which pass the Action Test will be subjected to Data
Test & those which pass the Action Test will be subjected to Category Test
Thank You

Facebook.com/PerpetroTech

Office Address
New No 30/1
Velachery Road, Little Mount
Saidapet, Chennai-15

Website: www.perpetrotech.com
Mail: info@perpetrotech.com
Ph: +91- 8939707287

More Related Content

PPTX
Android webinar class_3
PDF
Ch5 intent broadcast receivers adapters and internet
PPTX
ASP.NET MVC controllers
PPTX
Android application development
PDF
Android activity
PDF
Active Object Design Pattern
PPTX
Android eclipse project structure
ODP
Android App Development - 02 Activity and intent
Android webinar class_3
Ch5 intent broadcast receivers adapters and internet
ASP.NET MVC controllers
Android application development
Android activity
Active Object Design Pattern
Android eclipse project structure
Android App Development - 02 Activity and intent

Similar to Android activity intents (20)

PPTX
App Fundamentals and Activity life cycle.pptx
PPTX
Android development session 2 - intent and activity
PDF
android_mod_3.useful for bca students for their last sem
PPTX
Basics 4
PPT
android activity
PPT
ANDROID
PPTX
Android activity
PPTX
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
DOCX
Android building blocks and application life cycle-chapter3
PDF
Intents in Android
PPT
Intent, Service and BroadcastReciver (2).ppt
ODP
Ppt 2 android_basics
PPTX
Intents
PPT
Android - Android Intent Types
PPTX
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
PPTX
MAD unit 5.pptxyfc8yct7xugxigc8yc8c7yc7gc8yc
PDF
Android Basic Components
PPTX
learn about Android Extended Intents.pptx
PDF
Yourstory Android Workshop
PDF
Introduction to Android Programming
App Fundamentals and Activity life cycle.pptx
Android development session 2 - intent and activity
android_mod_3.useful for bca students for their last sem
Basics 4
android activity
ANDROID
Android activity
MAD Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxx
Android building blocks and application life cycle-chapter3
Intents in Android
Intent, Service and BroadcastReciver (2).ppt
Ppt 2 android_basics
Intents
Android - Android Intent Types
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
MAD unit 5.pptxyfc8yct7xugxigc8yc8c7yc7gc8yc
Android Basic Components
learn about Android Extended Intents.pptx
Yourstory Android Workshop
Introduction to Android Programming
Ad

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
cuic standard and advanced reporting.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
A Presentation on Artificial Intelligence
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Cloud computing and distributed systems.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Assigned Numbers - 2025 - Bluetooth® Document
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
sap open course for s4hana steps from ECC to s4
MYSQL Presentation for SQL database connectivity
Spectral efficient network and resource selection model in 5G networks
cuic standard and advanced reporting.pdf
Empathic Computing: Creating Shared Understanding
A comparative analysis of optical character recognition models for extracting...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Network Security Unit 5.pdf for BCA BBA.
Encapsulation_ Review paper, used for researhc scholars
A Presentation on Artificial Intelligence
The Rise and Fall of 3GPP – Time for a Sabbatical?
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation
Assigned Numbers - 2025 - Bluetooth® Document
The AUB Centre for AI in Media Proposal.docx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Ad

Android activity intents

  • 1. Welcome Every Day is a new Beginning
  • 2. Major Application components Any Android application must have at least one amongst the following components: • Activity • Intent & Intent Filters • Broadcast Receivers • Services • Content Providers
  • 3. Activity •Activity is an application component which provides User Interface(UI) to any application •An application can have any number of activities but only one of them can have the focus at any given time of the application’s visible lifetime •All other activities are moved to a “back-stack” which uses First In First Out (FIFO) mechanism to handle those activities •All activities have a set of methods known as “Callback methods”, which will get triggered during different stages of an Activity lifecycle •Views control rectangular space within an activity & interacts with the user •Widgets = Views + Visual elements + business logic •Layouts are special type of Views, which are derived from ViewGroup group
  • 5. Activity – Callback methods • onCreate() – triggered when the Activity is created • onStart() – triggered when the Activity is started • onResume() – triggered when the Activity is resumed after pause • onPause() – triggered when the Activity is paused • onStop() – triggered when the Activity goes out to background stack • onDestroy() – triggered when the Activity is destroyed
  • 6. States of an Activity An activity can be in anyone of the states in its entire lifecycle: • Resumed – Activity is in running • Paused – Activity is paused & visible in the background • Stopped – Activity is paused & not visible in the background ( in backstack)
  • 7. Start & Stop an Activity • An activity can be started in two ways : • • Using startActivity(Intent intent) method Using startActivityForResult(int reqCode,int resCode, Intent data) method • The first method is used to start an activity normally • The second method is used to start an activity when a specific resultant action is expected. Eg. Choose a phone contact from Contacts application • If an activity is started using second method, the control will be passed to this method after the expected result – onActivityResult() • An activity can be stopped/killed in ways: • • Using finishActivity() method (Recommended) Using finish() method
  • 8. How to start an Activity • An activity can be started from another activity using another application component called Intent. • A java class with name Sample.java, which extends Activity class must be created. • An entry in AndroidManifest.xml file should be included • A layout XML file must be created and proper layout should be created in XML file • Code snipped to start an activity (using its name): Intent intent = new Intent(this, Sample.class); startActivity(intent);
  • 9. How to start an Activity • An activity can also be started without explicitly stating its name but the action that it can perform Steps: • A java class with name Sample.java, which extends Activity class must be created. • An entry in AndroidManifest.xml file is included & an action is defined in Intent_Filter tag • A layout XML file is created and proper layout is created in XML file • Code snipped to start an activity (using its name): Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, recipientArray); startActivity(intent);
  • 10. Intents • Application components are activated through messages called Intents • Intents provide a facility for late runtime binding between components of same application or different applications as well • Basically, it is a passive data structure, which holds an abstract definition of an action performed or to be taken • It is used to start Activities using “startActivity(intent)” method • It is also used to start or bind Services using “startService(intent)” and “bindService(intent)” methods • It is also used to send broadcasts using “sendStickyBroadcast(intent)” methods
  • 11. Intent Objects Every Intent contains at least one of the following objects: 1. Component Name [optional] – Component with Intent is associated 2. Action (mandatory) 3. Category (mandatory at least once) – Category of Action 4. Data [optional & depends on type of Action] – URI & MIME type of data needed to complete Action 5. Extras [optional] – Data needed to complete Action 6. Flags [optional] – Eg. Which task the activity should belong to ?
  • 12. Intent Types Intents can be classified into following two types: • Explicit Intents – Associated component name is explicitly mentioned Intent intent1 = new Intent(this,ActivityTwo.class); startActivity(intent); • Implicit Intents – Associated component name is implied (not mentioned) Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, recipientArray); startActivity(intent);
  • 13. Intent Types & Resolution Intent Resolution : • Intents are resolved after undergoing three tests by Intent Filter • Intent Filter filters the suitable components based on the expected action and other input data 1. 2. 3. Intent Filter performs the tests in the following order and finally resolves the component(s) associated with the Intent Action Test Data Test Category Test • Those components which pass the Action Test will be subjected to Data Test & those which pass the Action Test will be subjected to Category Test
  • 14. Thank You Facebook.com/PerpetroTech Office Address New No 30/1 Velachery Road, Little Mount Saidapet, Chennai-15 Website: www.perpetrotech.com Mail: info@perpetrotech.com Ph: +91- 8939707287