INTENTS android.content.intent

Similar documents
Android User Interface Android Smartphone Programming. Outline University of Freiburg

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

Android User Interface

Intents and Intent Filters

<uses-permission android:name="android.permission.internet"/>

FRAGMENTS.

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

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

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

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Using Intents to Launch Activities

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

BCS3283-Mobile Application Development

Mobile Application Development Android

Introduction to Android Development

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

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

CS 193A. Multiple Activities and Intents

Multiple Activities. Many apps have multiple activities

ANDROID PROGRAMS DAY 3

Creating a User Interface

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

Basic GUI elements - exercises

Introduction to Android Multimedia

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

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

Intents & Intent Filters. codeandroid.org

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Android Programs Day 5

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

8Messaging SMS MESSAGING.

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

Android Beginners Workshop

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

Mobile Development Lecture 8: Intents and Animation

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Fragments. Lecture 11

Android Application Development

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

Android Intents. Notes are based on: Android Developers

Android Application Development. By : Shibaji Debnath

Android HelloWorld - Example. Tushar B. Kute,

CS378 -Mobile Computing. Intents

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu

Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

Android framework overview Activity lifecycle and states

Android Programming Lecture 7 9/23/2011

Stanislav Rost CSAIL, MIT

CS 234/334 Lab 1: Android Jump Start

This lecture. The BrowserIntent Example (cont d)

Introduction To Android

Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]

GUI Widget. Lecture6

Interworking Guide for Android Samsung Apps

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.

Hybrid Apps Combining HTML5 + JAVASCRIPT + ANDROID

Understanding Application

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

ES E 3 3 L a L b 5 Android development

Understanding Intents and Intent Filters

Vienos veiklos būsena. Theory

Our First Android Application

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

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

Android UI Development

The Internet. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046

Developing Android Applications

Introduction To JAVA Programming Language

else if(rb2.ischecked()) {

Answers to Exercises

Press project on the left toolbar if it doesn t show an overview of the app yet.

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

Eventually, you'll be returned to the AVD Manager. From there, you'll see your new device.

App Development for Smart Devices. Lec #18: Advanced Topics

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu

CS 4330/5390: Mobile Application Development Exam 1

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Fragments. Lecture 10

14.1 Overview of Android

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

University of Babylon - College of IT SW Dep. - Android Assist. Lect. Wadhah R. Baiee Activities

Android Workshop: Model View Controller ( MVC):

ANDROID APPS (NOW WITH JELLY BEANS!) Jordan Jozwiak November 11, 2012

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

Android Application Development 101. Jason Chen Google I/O 2008

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

stolen from Intents and Intent Filters

Programming with Android: System Architecture. Dipartimento di Scienze dell Informazione Università di Bologna

CMSC436: Fall 2013 Week 3 Lab

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Android - Widgets Tutorial

EMBEDDED SYSTEMS PROGRAMMING Android Services

Transcription:

INTENTS

INTENTS Intents are asynchronous messages which allow application components to request functionality from other Android components. Intents allow you to interact with components from the same applications as well as with components contributed by other applications. For example, an activity can start an external activity for taking a picture.

INTENTS Intents are objects of the android.content.intent type. Your code can send them to the Android system defining the components you are targeting. For example, via the startactivity() method you can define that the intent should be used to start an activity. An intent can contain data via a Bundle. This data can be used by the receiving component.

INTENTS Android intents are mainly used to: Start the service Launch an activity Display a web page Display a list of contacts Broadcast a message Dial a phone call etc.

INTENTS Android intents are used to: Open another Activity or Service from the current Activity Pass data between Activities and Services Delegate responsibility to another application. For example, you can use Intents to open the browser application to display a URL.

Types of Android Intents There are two types of intents in android. Implicit Intents Explicit Intents

Implicit Intents Implicit Intent doesn't specify the component. Intent provides information of available components provided by the system that is to be invoked. Intent intent=new Intent(Intent.ACTION_VIEW); intent.setdata(uri.parse("http://www.msrit.edu")); startactivity(intent);

Explicit Intents Explicit Intent specifies the component. Intent provides the external class to be invoked. Intent intent = new Intent(getApplicationContext(), SecondActivity.class); startactivity(intent);

Implicit Intent Example In the activity_main.xml create two buttons <Button android:id="@+id/btn_makecalls" <Button android:id="@+id/btn_webbrowser" android:layout_width="fill_parent" android:layout_height="wrap_conte nt" android:text="web Browser" /> android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_margintop="172dp" android:text="make Calls" />

Implicit Intent Example In MainActivity.java file add action listener for the first button. b1 = (Button) findviewbyid(r.id.btn_webbrowser); b1.setonclicklistener(new OnClickListener() { } }); public void onclick(view v){ Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); startactivity(i);

Implicit Intent Example In MainActivity.java file add action listener for the second button. b2 = (Button) findviewbyid(r.id.btn_makecalls); b2.setonclicklistener(new OnClickListener() { } }); public void onclick(view v){ Intent i = new Intent(android.content.Intent.ACTION_DIAL, Uri.parse("tel:+651234567")); startactivity(i);

Implicit Intent Example In Android, intents usually come in pairs: action and data. The action describes what is to be performed, such as editing an item, viewing the content of an item, and so on. The data specifies what is affected, such as a person in the Contacts database. The data is specified as an Uri object. Some examples of action are as follows: ACTION_VIEW ACTION_DIAL

Implicit Intent Example Collectively, the action and data pair describes the operation to be performed. For example, to dial a phone number, you would use the pair ACTION_DIAL/tel:+651234567. To display a list of contacts stored in your phone, you use the pair ACTION_VIEW/content://contacts. To pick a contact from the list of contacts, you use the pair ACTION_PICK/content://contacts.

Implicit Intent Example Intent i = new Intent( android.intent.action.view, Uri.parse( http://www.amazon.com )); startactivity(i); OR Intent i = new Intent( android.intent.action.view ); i.setdata(uri.parse( http://www.amazon.com )); startactivity(i);

Explicit Intent Create a new Android Project. Right-click on the package name under the src folder and select New Class. Name it as SecondActivity.java Create one xml file in res/layout folder and name it as secondactivity.xml Populate the second activity using secondactivity.xml file Add a button in activity_main.xml and modify <Button android:layout_width= fill_parent android:layout_height= wrap_content android:text= Display second activity android:onclick= onclick />

Explicit Intent Modify MainActivity.java file: public void onclick(view view) { } startactivity(new Intent( com.example.testintent.secondactivity ));

Explicit Intent Modify AndroidManifest.xml file: <activity android:name="com.example.testintent.secondactivity android:label="second Activity" > <intent-filter> <action android:name="com.example.testintent.secondactivity" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity>

Explicit Intent

The End