Introducing Intents Intents Bind application components and navigate between them Transform device into collection of interconnected systems Creating a.

Slides:



Advertisements
Similar presentations
Programming with Android: Activities and Intents
Advertisements

CE881: Mobile and Social Application Programming Simon M. Lucas Quiz, Walkthrough, Exercise, Lifecycles, Intents.
Application Fundamentals Android Development. Announcements Posting in D2L Tutorials.
Programming with Android: Activities and Intents Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Programming with Android: Activities and Intents Luca Bedogni Marco Di Felice Dipartimento di Informatica – Scienza e Ingegneria Università di Bologna.
Android 02: Activities David Meredith
Intents.
Manifest File, Intents, and Multiple Activities. Manifest File.
Mobile Programming Pertemuan 6 Presented by Mulyono Poltek NSC Surabaya.
Intent An Intent describes the operation to be performed. Intents are used to start an activity using either of the following methods – Context.startActivity()
박 종 혁 컴퓨터 보안 및 운영체제 연구실 MobiSys '11 Proceedings of the 9th international conference on Mobile systems, applications,
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Mobile Computing Lecture#08 IntentFilters & BroadcastReceivers.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
CSS216 MOBILE PROGRAMMING Android, Chapter 5 Book: “Professional Android™ 2 Application Development” by Reto Meier, 2010 by: Andrey Bogdanchikov (
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
Intent Android Club Agenda Intent class Explicit activation Implicit activation.
Using Intents to Broadcast Events Intents Can be used to broadcast messages anonymously Between components via the sendBroadcast method As a result Broadcast.
Android ICC Part II Inter-component communication.
CS378 - Mobile Computing Intents.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
COMP 365 Android Development.  Every android application has a manifest file called AndroidManifest.xml  Found in the Project folder  Contains critical.
Intent Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Lec 03 Intents Explicit Intents Implicit Intents.
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
Linking Activities using Intents How to navigate between Android Activities 1Linking Activities using Intents.
Activity Android Club Agenda Hello Android application Application components Activity StartActivity.
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
Android - Location Based Services. Google Play services facilitates adding location awareness to your app with automated location tracking Geo fencing.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Creating multiple views Introduction to intents Passing data to.
Lec 04 Intents and Bundles Fragments. Activated by Intents Activities Services Broadcast Receivers (aka Receivers) (
Intents 1 CS440. Intents  Message passing mechanism  Most common uses:  starting an Activity (open an , contact, etc.)  starting an Activity.
Android Intents Nasrullah. Using the application context You use the application context to access settings and resources shared across multiple activity.
Lecture 2: Android Concepts
Technische Universität München Services, IPC and RPC Gökhan Yilmaz, Benedikt Brück.
Activities and Intents Chapter 3 1. Objectives Explore an activity’s lifecycle Learn about saving and restoring an activity Understand intents and how.
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Putting together the AndroidManifest.xml file Creating multiple.
Editing a Twitter search. Viewing search results in a browser.
CS371m - Mobile Computing Intents 1. Allow us to use applications and components that are already part of Android System – start activities – start services.
Android Mobile Application Development
More Security and Programming Language Work on SmartPhones
Mobile Applications (Android Programming)
Intents and Broadcast Receivers
Lecture 2: Android Concepts
several communicating screens
CS499 – Mobile Application Development
Programming with Android:
Android 5: Interacting with Other Apps
Linking Activities using Intents
Lecture 3 agenda A tour of Android studio features
Activities and Intents
Android Introduction Camera.
Android Programming Lecture 9
CS371m - Mobile Computing Intents.
Android Programming Lecture 5
Many thanks to Jun Bum Lim for his help with this tutorial.
Activities and Intents
Android Topics What are Intents? Implicit Intents vs. Explicit Intents
Activities and Intents
Android Developer Fundamentals V2 Lesson 5
Activities and Intents
It is used to Start an Activity Start a Service Deliver a Broadcast
Lecture 2: Android Concepts
Objects First with Java
Mobile Programming Dr. Mohsin Ali Memon.
Chapter 5 Your Second Activity.
Activities, Fragments, and Intents
Presentation transcript:

Introducing Intents Intents Bind application components and navigate between them Transform device into collection of interconnected systems Creating a workflow of different screens Can be used to either Start a new activity explicitly Start an activity implicitly Broadcast that an event has occured

Explicitly Starting New activities To start a specific activity The startActivity() method Finds and starts the single activity matching your intent by explicitly specifying the Activity class to open (see above) Or by including an action that the target activity is able to perform  In which case, an activity is chosen dynamically  Through a process called intent resolution Example “UsingExplicitIntent” Android project

Implicit intents and Runtime Binding Implicit intent Allows you to ask the system to start an activity Without knowing which application will be started Constructed by Specifying an action to perform and data to act upon  data can be passed using setData method Android resolves an intent into an activity class

Native Android Actions ACTION_VIEW Data supplied to be viewed in the most reasonable manner ACTION_CALL Brings up a dialer and immediately initiates a call In this case, Android.permission.CALL_PHONE should be added to the app

Determining if an Intent will Resolve It is good practice To determine if your call resolves to an Activity Before calling startActivity

Using Intent Filters to Service Implicit Intents How does Android know Which app to use to service a request? Using intent filters, apps can declare actions and data they support So, add an intent-filter tag to the manifest node with tags:  action: android:name specifies the name of action  category: android:name condition to service the action  data: which data types you can act on

Example: loading URL

How Android Resolves Intent Filters Deciding which activity to start with an implicit intent Is called intent resolution The aim is find the best filter match possible  Create a list of all intent filters  Intent filters not matching action or category are removed  Any mismatch between URI and data tag => removal  More than one matches => all possibilities offered to user To find intent used to start activity

Example: adding categories

Obtaining Data from Another Activity To call an activity and wait for a result startActivityForResult() should be used In the called activity Use an Intent object to send data back via setData(), setResult() In the calling activity Override onActivityResult() to handle the returned data

How to Set Data in Called Activity? setResult Sets a result code RESULT_OK or RESULT_CANCELED finish Closes the activity and returns control to calling activity

How to Retrieve Data in Calling Activity requestCode The code used to launch the called activity resultCode The result code set by called activity Data Intent received from called activity and encompassing data

Passing Primitive Data Using the Received Intent Object