Intent Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.

Slides:



Advertisements
Similar presentations
Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
Advertisements

Programming with Android: Activities and Intents
Lecture 4 Sending and Receiving Messages Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
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.
Lecture 2b Sockets Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Lecture 1 Introduction to Java Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Introduction to C# Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Intents.
Manifest File, Intents, and Multiple Activities. Manifest File.
Mobile Application Development
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()
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
Better reference the original webpage :
PROG Mobile Java Application Development PROG Mobile Java Application Development Event Handling Creating Menus.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 4-1 of…
Intent Android Club Agenda Intent class Explicit activation Implicit activation.
Integrating with Android Services. Introduction  Android has numerous built-in functionality that can be called from within your applications  SMS/MMS.
Erika Chin Adrienne Porter Felt Kate Greenwood David Wagner University of California Berkeley MobiSys 2011.
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.
Android Development 1 Yuliana Setiowati Rizky Yuniar Hakkun Ahmad Syauqi Ahsan.
© 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.
Webview and Web services. Web Apps You can make your web content available to users in two ways in a traditional web browser in an Android application,
Lecture 3 Abstract Data Type Sandy Ardianto & Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
BASH – Text Processing Utilities Erick, Joan © Sekolah Tinggi Teknik Surabaya 1.
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Creating multiple views Introduction to intents Passing data to.
Lecture 3 Threads Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Lec 04 Intents and Bundles Fragments. Activated by Intents Activities Services Broadcast Receivers (aka Receivers) (
Introducing Intents Intents Bind application components and navigate between them Transform device into collection of interconnected systems Creating a.
Error Handling Tonga Institute of Higher Education.
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
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.
Lecture 6 Threads Erick Pranata
Android Mobile Application Development
Permissions.
Intents and Broadcast Receivers
Lecture 2: Android Concepts
Android 5: Interacting with Other Apps
Linking Activities using Intents
Activities and Intents
Mobile Application Development BSCS-7 Lecture # 3
CS371m - Mobile Computing Intents.
Android Programming Lecture 5
First form of our mobile application:
Activities and Intents
Android Topics What are Intents? Implicit Intents vs. Explicit Intents
Add to the Coffee Ordering App
Activities and Intents
Emerging Platform#3 Android & Programming an App
slide to unlock 10:32 AT&T Saturday, April 5 slide to unlock 11:24
Activities and Intents
It is used to Start an Activity Start a Service Deliver a Broadcast
Lecture 2: Android Concepts
Mobile Programming Dr. Mohsin Ali Memon.
Android Development Tools
Presentation transcript:

Intent Erick Pranata © Sekolah Tinggi Teknik Surabaya 1

» An object that provides runtime binding between separate components (such as two activities) » The Intent represents an app’s "intent to do something.“ ˃You can use intents for a wide variety of tasks, but most often they’re used to start another activity. » Types of Intent ˃Explicit ˃Implicit 2 © Sekolah Tinggi Teknik Surabaya

3

Intent intent = new Intent( theContext, theActivityClass); » theContext : Who owns the Intent » TheActivityClass : to which the system should deliver the Intent (in this case, the activity that should be started) 4 © Sekolah Tinggi Teknik Surabaya

» Intent may contain data to be passed to other Activity. intent.putExtra( "KEY_STRING", message ); » Best practice: use static constant to define "KEY_STRING" 5 © Sekolah Tinggi Teknik Surabaya

» Send more data as an object using bundle Bundle myBundle = new Bundle(); myBundle.putInt("val1", 123); intent.putExtras(myBundle); 6 © Sekolah Tinggi Teknik Surabaya

startActivity(intent); » Based on Intent object that was already instantiated 7 © Sekolah Tinggi Teknik Surabaya

» Every Activity is invoked by an Intent, regardless of how the user navigated there. » You can get the Intent that started your activity by calling getIntent() and retrieve the data contained within it. Intent intent = getIntent(); String message = intent.getStringExtra( MainActivity.CONSTANT_NAME ); 8 © Sekolah Tinggi Teknik Surabaya

Bundle myBundle = intent.getExtras(); int x = myBundle.getint("val1"); 9 © Sekolah Tinggi Teknik Surabaya

10

» It does not specify the app component to start, but instead specifies an action and provides some data with which to perform the action. » The system resolves the intent to an app that can handle the intent and starts its corresponding Activity. » If there's more than one app that can handle the intent, the system presents the user with a dialog to pick which app to use. 11 © Sekolah Tinggi Teknik Surabaya

» If there are no apps on the device that can receive the implicit intent, your app will crash when it calls startActivity(). ˃ Use resolveActivity() +If the result is non-null, there is at least one app that can handle the intent 12 © Sekolah Tinggi Teknik Surabaya

» Alarm Clock Alarm Clock » Calendar Calendar » Camera Camera » Contacts/People App Contacts/People App » » File Storage File Storage » Maps Maps » Music or Video Music or Video » Phone Phone » Settings Settings » Text Messaging Text Messaging » Web Browser Web Browser 13 © Sekolah Tinggi Teknik Surabaya

Intent common = new Intent(action, data); 14 © Sekolah Tinggi Teknik Surabaya

ActionData ACTION_VIEWUri.parse(" ACTION_WEB_SEARCHUri.parse(" ACTION_DIALUri.parse("tel: ") ACTION_CALLUri.parse("tel: ") ACTION_VIEWUri.parse("geo:0,0?z=4&q=business+near+city“) ACTION_SENDTOUri.parse("sms: ") 15 © Sekolah Tinggi Teknik Surabaya Some actions require permissions. Refer to

© Sekolah Tinggi Teknik Surabaya 16

© Sekolah Tinggi Teknik Surabaya 17

» Before an activity exits, it can call setResult(resultCode) to return a termination signal back to its parent. » Always supply a result code, which can be the standard results Activity.RESULT_CANCELED, Activity.RESULT_OK, or any custom values. » If a child activity fails for any reason (such as crashing), the parent activity will receive a result with the code RESULT_CANCELED. 18 © Sekolah Tinggi Teknik Surabaya

» Starting Another Activity, /basics/firstapp/starting-activity.html /basics/firstapp/starting-activity.html » Common Intents, mponents/intents-common.html mponents/intents-common.html 19 © Sekolah Tinggi Teknik Surabaya