SlideShare a Scribd company logo
1 of 24
Download to read offline
Ac#vity & Intent
[Recap] What is Ac#vity?
Ac$vity
Ac$vity class takes care of crea$ng a
window for you in which you can place
your UI
Introduc#on to Ac#vity
•  Ac$vity is one of the core and key
system in Android
•  Very important, you can’t just
know about it, you have to
MASTER at it
•  Key message to fully understand:
•  Lifecycle
Play around: Hide The Title Bar
1)  Hide by Code
2)  Hide by Style
Why do we hide it?
Live DemoCustom Title Bar No Title Bar at all
Play around: Styles & Theme
Naviga#on: The second Ac#vity
1)  Create New Ac$vity
2)  Try to startActivity
3)  See what happened?
4)  Play around with AndroidManifest.xml
5)  Now try again
Live Demo
Intent
An Intent is a messaging object
you can use to request an ac$on
from another app component.
Live Demo
?
Lab: Intent & Bundle
Q: Why we need to send data through Intent?
A: Because Ac)vity is independent to each other
… Play Play Play …
Understand how Android OS works
•  Secret: Actually Launcher
(Home Screen) is also an
Ac$vity !
•  And launcher also launch
our applica$on through
Intent and startActivity
Live Demo
Intent Filter
<activity
android:name="com.example.helloworld.MainActivity"
android:theme="@style/AppTheme"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Take a look into AndroidManifest.xml
What happened when app launched?
Tasks and Back Stack
Live Demo
The Ac#vity Lifecycle
IMPORTANT ALERT
The Ac#vity Lifecycle #2
What do we do in each lifecycle event in prac#cal?
onCreate
Ini$alize UI Elements
onResume or onStart
Ini$alize System
Resources (GPS,
Camera, etc)
onDestroy
Mostly do nothing
onPause or onStop
Release System
Resources (GPS,
Camera, etc)
Stop CPU consuming
task like Anima$on,
Timer
Commit unsaved
changes
Pause Game
Why or?
Save & Restore Instance State
Live Demo
You will a liOle bit confuse now
But it will be be^er when you prac$ce more
(and more)
(and more)
(and more)
Best Prac#ces: Ac#vity Code Structure
•  In The Android Cheese Sheet
How to return from Ac#vity
Live Demo
finish()
FirstAc)vity
startActivity(...)
SecondAc)vity
GeRng a Result from an Ac#vity
Live Demo
setResult(...);
finish()
FirstAc)vity
startActivityForResult(...)
SecondAc)vity
The Screen Orienta#on
android:screenOrientation=["unspecified" | "behind" |
"landscape" | "portrait" |
"reverseLandscape" | "reversePortrait" |
"sensorLandscape" | "sensorPortrait" |
"userLandscape" | "userPortrait" |
"sensor" | "fullSensor" | "nosensor" |
"user" | "fullUser" | "locked"]
Live Demo
You can fix the Ac$vity’s orienta$on in AndroidManifest.xml
Sugges$on: Fix Orienta$on to portrait at the beginning
(why?)
SoS Keyboard Mode
android:windowSoftInputMode=["stateUnspecified",
"stateUnchanged",
"stateHidden",
"stateAlwaysHidden",
"stateVisible",
"stateAlwaysVisible",
"adjustUnspecified",
"adjustResize",
"adjustPan"]
Live Demo
You can change behavior of sod keyboard in Ac$vity through
AndroidManifest.xml
Ac#vity Transi#on
•  Basically transi$on will be done by default seengs
•  But you can override it (but not so recommend unless it is by design)
•  Example: <?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="2000" />
res/anim/fade_in.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha=“1.0" android:toAlpha=“0.0" android:duration="2000" />
res/anim/fade_out.xml
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
Recap
•  Every$me you create a new Ac$vity, declare in AndroidManifest.xml
immediately
•  Ac)vity Lifecycle is very very very important
•  In can effect your lifecycle as an Android App Developer as well
•  Most of the Android Developer doesn’t know about Lifecycle clearly and
that lead to app’s quality problem
•  Crash
•  Malfunc$onal
Ac#vity Types
Ac$vity
ListAc$vity PreferenceAc$vity LauncherAc$vity FragmentAc$vity
Ac$onBarAc$vity
AppCompatAc$vity
…

More Related Content

Viewers also liked

Viewers also liked (8)

Faierman gladys cam_studio
Faierman gladys cam_studioFaierman gladys cam_studio
Faierman gladys cam_studio
 
resume word
resume wordresume word
resume word
 
Chapter 6 - Views Part 1
Chapter 6 - Views Part 1Chapter 6 - Views Part 1
Chapter 6 - Views Part 1
 
Chapter 7 - Debugging part 1
Chapter 7 - Debugging part 1Chapter 7 - Debugging part 1
Chapter 7 - Debugging part 1
 
Faierman gladys ardora
Faierman gladys ardoraFaierman gladys ardora
Faierman gladys ardora
 
Chapter 11 - Styling Theming
Chapter 11 - Styling ThemingChapter 11 - Styling Theming
Chapter 11 - Styling Theming
 
Proceso de comunicación 3
Proceso de comunicación 3Proceso de comunicación 3
Proceso de comunicación 3
 
Chapter 8 - Dimension Units
Chapter 8 - Dimension UnitsChapter 8 - Dimension Units
Chapter 8 - Dimension Units
 

Similar to Chapter 12 - Activity Intent

Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil TayarVisual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil TayarApplitools
 
[University] Capstone Design Project 2 (SAIOT)
[University] Capstone Design Project 2 (SAIOT)[University] Capstone Design Project 2 (SAIOT)
[University] Capstone Design Project 2 (SAIOT)창엽 양
 
Android Programming made easy
Android Programming made easyAndroid Programming made easy
Android Programming made easyLars Vogel
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2dVinsol
 
Migrating Objective-C to Swift
Migrating Objective-C to SwiftMigrating Objective-C to Swift
Migrating Objective-C to SwiftElmar Kretzer
 
Game development via_sprite_kit
Game development via_sprite_kitGame development via_sprite_kit
Game development via_sprite_kitBuşra Deniz, CSM
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x EngineDuy Tan Geek
 
Lesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ayLesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ayCodecademy Ren
 
Android webinar class_4
Android webinar class_4Android webinar class_4
Android webinar class_4Edureka!
 
Back To The Future.Key 2
Back To The Future.Key 2Back To The Future.Key 2
Back To The Future.Key 2gueste8cc560
 
Advanced #4 GPU & Animations
Advanced #4   GPU & AnimationsAdvanced #4   GPU & Animations
Advanced #4 GPU & AnimationsVitali Pekelis
 
iOS for Android Developers (with Swift)
iOS for Android Developers (with Swift)iOS for Android Developers (with Swift)
iOS for Android Developers (with Swift)David Truxall
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1benDesigning
 
Y1 gd engine terminology
Y1 gd engine terminologyY1 gd engine terminology
Y1 gd engine terminologyKeatonBradley
 
Integrate connections and twitter
Integrate connections and twitterIntegrate connections and twitter
Integrate connections and twitterStefano Pogliani
 
Rock the ActivityStream API
Rock the ActivityStream APIRock the ActivityStream API
Rock the ActivityStream APILetsConnect
 
Android game development
Android game developmentAndroid game development
Android game developmentdmontagni
 

Similar to Chapter 12 - Activity Intent (20)

SWT - Technical Deep Dive
SWT - Technical Deep DiveSWT - Technical Deep Dive
SWT - Technical Deep Dive
 
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil TayarVisual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
Visual Testing: The Missing Piece of the Puzzle -- presentation by Gil Tayar
 
[University] Capstone Design Project 2 (SAIOT)
[University] Capstone Design Project 2 (SAIOT)[University] Capstone Design Project 2 (SAIOT)
[University] Capstone Design Project 2 (SAIOT)
 
Android Programming made easy
Android Programming made easyAndroid Programming made easy
Android Programming made easy
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
Migrating Objective-C to Swift
Migrating Objective-C to SwiftMigrating Objective-C to Swift
Migrating Objective-C to Swift
 
Game development via_sprite_kit
Game development via_sprite_kitGame development via_sprite_kit
Game development via_sprite_kit
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x Engine
 
Cocos2d for beginners
Cocos2d for beginnersCocos2d for beginners
Cocos2d for beginners
 
Lesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ayLesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ay
 
Android webinar class_4
Android webinar class_4Android webinar class_4
Android webinar class_4
 
Back To The Future.Key 2
Back To The Future.Key 2Back To The Future.Key 2
Back To The Future.Key 2
 
Advanced #4 GPU & Animations
Advanced #4   GPU & AnimationsAdvanced #4   GPU & Animations
Advanced #4 GPU & Animations
 
iOS for Android Developers (with Swift)
iOS for Android Developers (with Swift)iOS for Android Developers (with Swift)
iOS for Android Developers (with Swift)
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
 
Y1 gd engine terminology
Y1 gd engine terminologyY1 gd engine terminology
Y1 gd engine terminology
 
Integrate connections and twitter
Integrate connections and twitterIntegrate connections and twitter
Integrate connections and twitter
 
Rock the ActivityStream API
Rock the ActivityStream APIRock the ActivityStream API
Rock the ActivityStream API
 
Node azure
Node azureNode azure
Node azure
 
Android game development
Android game developmentAndroid game development
Android game development
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Chapter 12 - Activity Intent