Intents. 18 December 2018 Lecture Dec 2018 SE 435: Development in the Android Environment 1

Similar documents
Programming with Android: Intents. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Programming with Android: Activities and Intents. Dipartimento di Informatica Scienza e Ingegneria Università di Bologna

Activities and Fragments

Software Practice 3 Today s lecture Today s Task Porting Android App. in real device

Multiple Activities. Many apps have multiple activities

Workshop. 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking

Mobile Application Development Android

Camera and Intent. Elena Fortini

CS 193A. Multiple Activities and Intents

Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

Using Intents to Launch Activities

The Intent Class Starting Activities with Intents. Explicit Activation Implicit Activation via Intent resolution

CMSC436: Fall 2013 Week 3 Lab

The Intent Class Starting Activities with Intents. Explicit Activation Implicit Activation via Intent resolution

Overview. Lecture: Implicit Calling via Share Implicit Receiving via Share Launch Telephone Launch Settings Homework

Mobile Development Lecture 8: Intents and Animation

Activities. Repo:

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu

Developing Android Applications

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu

Application Fundamentals

Android. Operating System and Architecture. Android. Screens. Main features

INTENTS android.content.intent

Android Programming Lecture 8: Activities, Odds & Ends, Two New Views 9/28/2011

Android Programming Lecture 7 9/23/2011

THE CATHOLIC UNIVERSITY OF EASTERN AFRICA A. M. E. C. E. A

Mobile Programming Lecture 9. Bound Services, Location, Sensors, IntentFilter

Why using intents. Activity. Screen1 Screen 2

Lifecycle Callbacks and Intents

Understanding Application

Intents and Intent Filters

App Development for Android. Prabhaker Matet

CMSC436: Fall 2013 Week 4 Lab

Minds-on: Android. Session 2

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu

Introduction to Android Development

Android Intents. Notes are based on: Android Developers

Understanding Intents and Intent Filters

Introduction to Android Multimedia

Accelerating Information Technology Innovation

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

else if(rb2.ischecked()) {

BCS3283-Mobile Application Development

Android Activities. Akhilesh Tyagi

Starting Another Activity Preferences

Outline. Admin. Example: TipCalc. Android: Event Handler Blocking, Android Inter-Thread, Process Communications. Recap: Android UI App Basic Concepts

Programmation Mobile Android Master CCI

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

Intents. Repo:

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

SMAATSDK. NFC MODULE ON ANDROID REQUIREMENTS AND DOCUMENTATION RELEASE v1.0

Interworking Guide for Android Samsung Apps

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Mobile Programming Practice Explicit intent Implicit intent Intent filter Lab#4 PA #1

Computer Science E-76 Building Mobile Applications

University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World

Mobile Programming Lecture 1. Getting Started

LECTURE 12 BROADCAST RECEIVERS

Android: Intents, Menus, Reflection, and ListViews

Overview of Activities

Android Tutorial: Part 3

Android User Interface Android Smartphone Programming. Outline University of Freiburg

Embedded Systems Programming - PA8001

Writing Efficient Drive Apps for Android. Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations

Intents. Your first app assignment

EMBEDDED SYSTEMS PROGRAMMING Application Basics

LECTURE NOTES OF APPLICATION ACTIVITIES

Lecture 1 Introduction to Android. App Development for Mobile Devices. App Development for Mobile Devices. Announcement.

Intents & Intent Filters. codeandroid.org

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism

05. RecyclerView and Styles

Mobile Application Development MyRent Settings

About 1. Chapter 1: Getting started with dagger-2 2. Remarks 2. Versions 2. Examples 2. Description and Setup 2. Basic Example 3.

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

Android writing files to the external storage device

Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26

How to start with Intelligent VOICE

DROIDS ON FIRE. Adrián

Modeling the Android Platform

Android User Interface

Intro to Android Development 3. Accessibility Capstone Dec 10, 2010

Android Help. Section 8. Eric Xiao

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based.

CS434/534: Topics in Networked (Networking) Systems

Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time

CE881: Mobile & Social Application Programming

Mobile Computing Practice # 2c Android Applications - Interface

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Android Programs Day 5

Android framework overview Activity lifecycle and states

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Android/Java Lightning Tutorial JULY 30, 2018

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

Transcription:

Intents 18 December 2018 Lecture 4 18 Dec 2018 SE 435: Development in the Android Environment 1

Topics for Today Building an Intent Explicit Implicit Other features: Data Result Sources: developer.android.com 18 Dec 2018 SE 435: Development in the Android Environment 2

Building an Intent Can add fields such as: Action: what do you want to happen Ex. ACTION_VIEW, ACTION_SEND URI: Data URI to examine or operate on Ex. content://com.android.email.attachmentprovider/1/62/raw Class: Which class should receive the intent Explicit intents: Have a Class Implicit intents: No Class 18 Dec 2018 SE 435: Development in the Android Environment 3

Sending an Explicit Intent public void sendexplicitnodata(view view) { // create an explicit intent to send Intent intent = new Intent(getBaseContext(), ExplicitActivityOne.class); startactivity(intent); } 1. The intent is sent to Android OS 2. The sender loses control of the screen 3. The intent is sent to the ExplicitActivityOne 4. ExplicitActivityOne starts to run with its lifecycle 18 Dec 2018 SE 435: Development in the Android Environment 4

Sending an Implicit Intent public void sendimplicitnodata(view view) { // create an explicit intent to send Intent intent = new Intent(Intent.ACTION_DIAL); startactivity(intent); } 1. Intent is sent with the desired action (dial) 2. The sender loses control of the screen 3. Android OS searches which apps can handle ACTION_DIAL 4. The chosen app starts to run with its lifecycle 18 Dec 2018 SE 435: Development in the Android Environment 5

Result 18 Dec 2018 SE 435: Development in the Android Environment 6

So Far Building an Intent Explicit Implicit Other features: Data Result 18 Dec 2018 SE 435: Development in the Android Environment 7

Adding Data public void sendimplicitdata (View view) { // create an implicit intent to send with data Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:97246653793")); startactivity(intent); } Added a data field to the Intent The scheme (tel:) indicates it s a telephone number 18 Dec 2018 SE 435: Development in the Android Environment 8

Result 18 Dec 2018 SE 435: Development in the Android Environment 9

Adding Extras public void sendimplicitextras (View view) { } // create an implicit intent to send with data Intent intent = new Intent(Intent.ACTION_SEND); intent.settype("text/rfc822"); intent.putextra(intent.extra_email, new String[]{"mjmay@kinneret.ac.il"}); intent.putextra(intent.extra_cc, new String[]{"yaely@kinneret.ac.il"}); intent.putextra(intent.extra_subject, "An implicit intent with extras"); intent.putextra(intent.extra_text, "This is the body of my message!"); startactivity(intent); 18 Dec 2018 SE 435: Development in the Android Environment 10

Sending and Routing MyApp Intent Action ACTION.SEND MIME type Rfc822 EXTRA EMAIL String[]{"mjmay@kinneret.ac.il"} EXTRA CC String[]{ yaely@kinneret.ac.il"} EXTRA SUBJECT "An implicit intent with extras" EXTRA TEXT "This is the body of my message!" GMail Binder Intent App Action MIME Type Category SEND text/rfc822 DEFAULT GMail SEND text/plain DEFAULT Reader VIEW application/pdf DEFAULT 18 Dec 2018 SE 435: Development in the Android Environment 11

Result 18 Dec 2018 SE 435: Development in the Android Environment 12

Receiving an Intent (1/2) public void sendexplicitdata (View view) { // create an explicit intent to send with // data Intent intent = new Intent(getBaseContext(), ExplicitActivityTwo.class); intent.putextra( ExplicitActivityTwo.EXTRA_NUMBERS, new int[]{25,72,43}); } startactivity(intent); 18 Dec 2018 SE 435: Development in the Android Environment 13

Receiving an Intent (2/2) public class ExplicitActivityTwo extends Activity { } public static final String EXTRA_NUMBERS = "il.ac.kinneret.mjmay.extra_numbers"; @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview( R.layout.activity_explicit_activity_two); Intent intent = getintent(); TextView tv = (TextView) findviewbyid(r.id.messageview); int[] values = intent.getextras().getintarray(extra_numbers); tv.settext(""); for (int i : values) { } tv.append(string.valueof(i) + "\n"); 18 Dec 2018 SE 435: Development in the Android Environment 14

Result 18 Dec 2018 SE 435: Development in the Android Environment 15

Sending an Intent for Result startactivityforresult (intent, mycode) 18 Dec 2018 SE 435: Development in the Android Environment 16

Sending an Intent for Result startactivityforresult (intent, mycode) OK? setresult(result_ok, returnintent) BAD? setresult(result_canceled, returnintent) finish() 18 Dec 2018 SE 435: Development in the Android Environment 17

Sending an Intent for Result startactivityforresult (intent, mycode) OK? setresult(result_ok, returnintent) BAD? setresult(result_canceled, returnintent) onactivityresult() with: mycode RESULT_OK/RESULT_CANCELED returnintent finish() 18 Dec 2018 SE 435: Development in the Android Environment 18

Conclusion Building an Intent Explicit Implicit Other features: Data Result 18 Dec 2018 SE 435: Development in the Android Environment 19