SlideShare a Scribd company logo
Android Programming




      Lesson 6
Intent and Activity

    NGUYEN The Linh
Android Programming


Contents


     1     Understanding Intents

     2     Activity


     3     Exercise 6




                          2
Android Programming


Intent and Activity




         Understanding Intents




                  3
Android Programming


 Understanding Intents


                         http://blog.nikmesoft.com



Verbs                                     URL




                   HTTP

                     4
Android Programming


Understanding Intents

 Just as a Web browser knows how to process a verb
  + URL pair, Android knows how to find activities or
  other application logic that will handle a given intent.

 You can use intents to represent actions.

 At the simplest level, an intent is an action that you
  can tell Android to invoke.




                            5
Android Programming


Understanding Intents




                    6
Android Programming


Understanding Intents

 Notes:
    android:exported: Whether or not the activity can be launched
     by components of other applications — "true" if it can be, and
     "false" if not.

    The general convention for an action name is <your-package-
     name>.intent.action.YOUR_ACTION_NAME.




                                 7
Android Programming


Understanding Intents

 Available Intents in Android
    http://developer.android.com/guide/appendix/g-app-intents.html
    A browser application to open a browser window
    An application to call a telephone number
    An application to present a phone dialer so the user can enter
     the numbers and make the call through the UI
    A mapping application to show the map of the world at a given
     latitude/longitude coordinate
    A detailed mapping application that can show Google stree
     views

                                 8
Android Programming


Event Listeners and Callback Methods

 Example 6.1 6.2




                    9
Android Programming


Understanding Intents

 Using Extra Information
    An extra can provide more information to the component that
     receives the intent.

    This extra information is repre-sented by an Android class called
     android.os.Bundle.

    The following two methods on an Intentclass provide access to
     the extra Bundle:


                                 10
Android Programming


Understanding Intents

 Using Extra Information (cont.)




                          11
Android Programming


Understanding Intents

 Using Extra Information (cont.)




                          12
Android Programming


Understanding Intents

 Using Components to Directly Invoke an Activity
    Android also provides a more direct way to start an activity: you
     can specify the activity’s ComponentName, which is an
     abstraction around an object’s package name and class name.




                                  13
Android Programming


Understanding Intents

 Using Components to Directly Invoke an Activity
  (cont.)
    ComponentName wraps a package name and a class name
     together. For example, the follow-ing code invokes the
     SubActivity:




                              14
Android Programming


Understanding Intents

 Using Components to Directly Invoke an Activity
  (cont.)
    You can also use the class name directly without constructing a
     ComponentName.




    You should register the activity in the AndroidManifest.xml file
     like this:
       •   <activity android:name=".SubActivity">


                                        15
Android Programming


Understanding Intents

 Using Components to Directly Invoke an Activity
  (cont.)

    No intent-filters are necessary for invoking an activity directly
     through its class name or component name.




                                   16
Android Programming


Intent and Activity




               Activity




                 17
Android Programming


Activity

 Activity Lifecycle
    Most management of the life cycle is done automatically by the
     system via the activity stack.
    The activity class has the following method callbacks to help you
     manage the app:
        •   onCreate()
        •   onStart()
        •   onResume()
        •   onPause()
        •   onStop()
        •   onRestart()
        •   onDestroy()
                                 18
Android Programming


Activity




                Activity
                Lifecycle




           19
Android Programming


Activity




                  Saving
                  activity
                   state




           20
Android Programming


Activity

 Launching Activities and Sub-Activities(cont.)



   Activity A          Activity B         Activity C




                           21
Android Programming


Activity

 Launching Activities and Sub-Activities(cont.)




    Activity A                            Activity B




                          22
Android Programming


Activity

 Launching Activities and Sub-Activities(cont.)




   Activity A                             Activity B



                         finish();
                           23
Android Programming


Activity

 Launching Activities and Sub-Activities(cont.)




                          24
Android Programming


Activity

 Launching Activities and Sub-Activities(cont.)
    The Request Code: The request code that was used to launch
     the returning sub-Activity

    A Result Code: The result code set by the sub-Activity to
     indicate its result. It can be any inte-ger value, but typically will
     be either Activity.RESULT_OK or
     Activity.RESULT_CANCELLED.




                                    25
Android Programming


Activity

 Launching Activities and Sub-Activities(cont.)
    If the sub-Activity closes abnormally or doesn’t specify a result
     code before it closes, the result code is
     Activity.RESULT_CANCELED.

     Data: An Intent used to bundle any returned data.




                                   26
Android Programming


Exercise 6




             27
Android Programming

More Related Content

PDF
Android development - Activities, Views & Intents
PDF
Android Lesson 3 - Intent
PPT
Android - Android Intent Types
PDF
Intents in Android
PDF
Android: Intent, Intent Filter, Broadcast Receivers
PDF
Android intent
PDF
Android Lesson 2
PPTX
Android development session 2 - intent and activity
Android development - Activities, Views & Intents
Android Lesson 3 - Intent
Android - Android Intent Types
Intents in Android
Android: Intent, Intent Filter, Broadcast Receivers
Android intent
Android Lesson 2
Android development session 2 - intent and activity

What's hot (20)

ODP
Android App Development - 02 Activity and intent
PDF
Android Basic Components
ODP
Ppt 2 android_basics
PPTX
Android apps development
PDF
Android intents
PDF
Android Introduction
PDF
Android Components & Manifest
PDF
Android UI Fundamentals part 1
PDF
Android Components
PPTX
05 intent
PPTX
Android components
PPTX
08.1. Android How to Use Intent (explicit)
PDF
Android activities & views
PPTX
B2. activity and intent
PPTX
Android intents, notification and broadcast recievers
PDF
Events and Listeners in Android
PPT
Android Bootcamp Tanzania: android manifest
PDF
Android App Development 07 : Intent &amp; Share
DOC
Day 4: Activity lifecycle
DOCX
Using intents in android
Android App Development - 02 Activity and intent
Android Basic Components
Ppt 2 android_basics
Android apps development
Android intents
Android Introduction
Android Components & Manifest
Android UI Fundamentals part 1
Android Components
05 intent
Android components
08.1. Android How to Use Intent (explicit)
Android activities & views
B2. activity and intent
Android intents, notification and broadcast recievers
Events and Listeners in Android
Android Bootcamp Tanzania: android manifest
Android App Development 07 : Intent &amp; Share
Day 4: Activity lifecycle
Using intents in android
Ad

Viewers also liked (19)

PDF
Intent in android
PPT
PDF
Android Lecture #01 @PRO&BSC Inc.
PDF
Intents are Awesome
PDF
[Android] Basic Widgets and Containers
PDF
[Android] Using Selection Widgets
PDF
[Android] Data Storage
PDF
[iOS] Networking
PDF
[iOS] Introduction to iOS Programming
PPTX
02 hello world - Android
PDF
Objective-C
PPTX
04 activities - Android
PDF
[Android] Introduction to Android Programming
PPTX
The android activity lifecycle
PDF
[Android] Widget Event Handling
PDF
02 programmation mobile - android - (activity, view, fragment)
PPTX
Android Activity Transition(ShareElement)
PDF
Introduction to Swift programming language.
PDF
Introduction to Android Studio
Intent in android
Android Lecture #01 @PRO&BSC Inc.
Intents are Awesome
[Android] Basic Widgets and Containers
[Android] Using Selection Widgets
[Android] Data Storage
[iOS] Networking
[iOS] Introduction to iOS Programming
02 hello world - Android
Objective-C
04 activities - Android
[Android] Introduction to Android Programming
The android activity lifecycle
[Android] Widget Event Handling
02 programmation mobile - android - (activity, view, fragment)
Android Activity Transition(ShareElement)
Introduction to Swift programming language.
Introduction to Android Studio
Ad

Similar to [Android] Intent and Activity (20)

PPT
Best android classes in mumbai
PDF
Dueling Banjos: Inter-app Communication
PPT
Android overview
PPTX
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
PPTX
Pertemuan 03 - Activities and intents.pptx
PPTX
learn about Android Extended Intents.pptx
PPTX
Android app fundamentals
PPTX
Intents
PPTX
Android101 - Intro and Basics
PDF
Android Development
PPTX
Android terminologies
PDF
Androidoscon20080721 1216843094441821-9
PDF
Androidoscon20080721 1216843094441821-9
PDF
Ch5 intent broadcast receivers adapters and internet
PPT
Ruby conf2012
PDF
Android Jump Start
PPT
Day 4: Android: Getting Active through Activities
PDF
Mobile Software Engineering Crash Course - C04 Android Cont.
PDF
Android in action
PPT
Android activity, service, and broadcast recievers
Best android classes in mumbai
Dueling Banjos: Inter-app Communication
Android overview
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
Pertemuan 03 - Activities and intents.pptx
learn about Android Extended Intents.pptx
Android app fundamentals
Intents
Android101 - Intro and Basics
Android Development
Android terminologies
Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9
Ch5 intent broadcast receivers adapters and internet
Ruby conf2012
Android Jump Start
Day 4: Android: Getting Active through Activities
Mobile Software Engineering Crash Course - C04 Android Cont.
Android in action
Android activity, service, and broadcast recievers

More from Nikmesoft Ltd (11)

PDF
[iOS] Data Storage
PDF
[iOS] Multiple Background Threads
PDF
[iOS] Navigation
PDF
[iOS] Basic UI Elements
PDF
[Android] Multimedia Programming
PDF
[Android] Android Animation
PDF
[Android] 2D Graphics
PDF
[Android] Services and Broadcast Receivers
PDF
[Android] Web services
PDF
[Android] Multiple Background Threads
PDF
[Android] Maps, Geocoding and Location-Based Services
[iOS] Data Storage
[iOS] Multiple Background Threads
[iOS] Navigation
[iOS] Basic UI Elements
[Android] Multimedia Programming
[Android] Android Animation
[Android] 2D Graphics
[Android] Services and Broadcast Receivers
[Android] Web services
[Android] Multiple Background Threads
[Android] Maps, Geocoding and Location-Based Services

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
Teaching material agriculture food technology
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
Machine Learning_overview_presentation.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Machine learning based COVID-19 study performance prediction
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Empathic Computing: Creating Shared Understanding
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Electronic commerce courselecture one. Pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Programs and apps: productivity, graphics, security and other tools
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Teaching material agriculture food technology
The Rise and Fall of 3GPP – Time for a Sabbatical?
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
Machine Learning_overview_presentation.pptx
A comparative analysis of optical character recognition models for extracting...
“AI and Expert System Decision Support & Business Intelligence Systems”
Machine learning based COVID-19 study performance prediction
Unlocking AI with Model Context Protocol (MCP)
Advanced methodologies resolving dimensionality complications for autism neur...
Empathic Computing: Creating Shared Understanding
sap open course for s4hana steps from ECC to s4
Digital-Transformation-Roadmap-for-Companies.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation_ Review paper, used for researhc scholars
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
Programs and apps: productivity, graphics, security and other tools

[Android] Intent and Activity