Android Mobile Application Development

Slides:



Advertisements
Similar presentations
Android Application Development A Tutorial Driven Course.
Advertisements

Programming with Android: Activities and 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.
The Web Warrior Guide to Web Design Technologies
Introduction to push technology © 2009 Research In Motion Limited.
Intents.
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()
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Lecture 3 agenda Layouts Intents (both explicit and implicit) ListViews and Adapters.
About me Yichuan Wang Android Basics Credit goes to Google and UMBC.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Intent Android Club Agenda Intent class Explicit activation Implicit activation.
Mobile Application Development using Android Lecture 2.
CS378 - Mobile Computing Intents.
Overview of Android Application Development
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.
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.
Linking Activities using Intents How to navigate between Android Activities 1Linking Activities using Intents.
XP Tutorial 8 Adding Interactivity with ActionScript.
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.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
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
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Putting together the AndroidManifest.xml file Creating multiple.
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
Android Mobile Application Development
Lecture 2: Android Concepts
WWW and HTTP King Fahd University of Petroleum & Minerals
Android Intent Filters
Programming with Android:
Android 5: Interacting with Other Apps
Lecture 3 agenda A tour of Android studio features
Play Framework: Introduction
MAD.
Android Mobile Application Development
CASE STUDY -HTML,URLs,HTTP
Processes The most important processes used in Web-based systems and their internal organization.
Mobile Application Development BSCS-7 Lecture # 3
Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
IS333D: MULTI-TIER APPLICATION DEVELOPMENT
Android Programming Lecture 9
CS371m - Mobile Computing Intents.
intro to notifications in iOS 10
Android Programming Lecture 5
Chapter 27 WWW and HTTP.
Phonegap Bridge Configuration file
Application Development A Tutorial Driven Course
Activities and Intents
Android Topics What are Intents? Implicit Intents vs. Explicit Intents
Add to the Coffee Ordering App
Activities and Intents
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.
Presentation transcript:

Android Mobile Application Development Intents and Filters Lecture Four Assistant Lecturer Mustafa Ghanem Saeed Computer science Department Collage Of Science Cihan University - Sulaimaniyah

What are 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 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. http://www.vogella.com/tutorials/AndroidIntent/article.html

Android intents are mainly used to: (Question) Open another Activity or Service from the current Activity Pass data between Activities and Services Give responsibility to another application. For example, you can use Intents to open the browser application to display a URL. Broadcast a message. Dial a phone call etc. http://www.javatpoint.com/android-intent-tutorial

Types of Android Intents (Question) Implicit Intent Implicit Intent specify the action which should be performed and optionally data which provides content for the action. For example, the following tells the Android system to view a webpage. All installed web browsers should be registered to the corresponding intent data via an intent filter.

Types of Android Intents (Question) cont. 2- Explicit intents explicitly define the component which should be called by the Android system, by using the Java class as identifier. The following code demonstrates how you can start another activity via an intent. http://www.vogella.com/tutorials/AndroidIntent/article.html

Types of Android Intents (Question) cont. use explicit intents to: start a new activity start an activity to get a result start a service broadcast an intent start a new activity from within a broadcast receiver use implicit intents to: use other app’s components to: send an email pick a contact from the contacts list make a phone call use a pending intent to send a notification https://www.101apps.co.za/articles/android-s-intents-and-intent-filters-a-tutorial.html

Intent Filters There are following Five elements in an intent filter: Action It represent an activities action, what an activity is going to do. Data There are two forms in which you can pass the data, using URI(Uniform Resource Identifiers) or MIME type of data Category This attribute of Intent filter dictates the behavior or nature of an Intent Extras Key-value pairs for additional information that should be delivered to the component handling the intent Flags These flags are optional part of Intent object and instruct the Android system how to launch an activity, and how to treat it after it's launched etc. Important Note: Every intent filter must contain action element in it. Data and category element is optional for it. http://abhiandroid.com/programming/intent-filter

Intent Filters-Action 1 The Intent class defines a number of action constants, including these: Constant Target component Action ACTION_CALL activity Initiate a phone call. ACTION_EDIT Display data for the user to edit. ACTION_MAIN Start up as the initial activity of a task, with no data input and no returned output. ACTION_SYNC Synchronize data on a server with data on the mobile device. The action largely determines how the rest of the intent is structured — particularly the data and extras fields — much as a method name determines a set of arguments and a return value. For this reason, it's a good idea to use action names that are as specific as possible, and to couple them tightly to the other fields of the intent. In other words, instead of defining an action in isolation, define an entire protocol for the Intent objects your components can handle. The action in an Intent object is set by the setAction() method and read by getAction(). http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html

Intent Filters-Action 2 The Intent class defines a number of action constants, including these: Constant Target component Action ACTION_BATTERY_LOW Broadcast Receiver A warning that the battery is low. ACTION_HEADSET_PLUG A headset has been plugged into the device, or unplugged from it. ACTION_SCREEN_ON The screen has been turned on. ACTION_TIMEZONE_CHANGED The setting for the time zone has changed. http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html

Intent Filters- Data The URI of the data to be acted on and the MIME type of that data. Different actions are paired with different kinds of data specifications. The URI: At the highest level a URI reference (Uniform Resource Identifiers) in string form has the syntax [scheme:]scheme-specific-part[#fragment] For example: Short for Multipurpose Internet Mail Extensions, a specification for formatting non-ASCII messages so that they can be sent over the Internet. For Examples: For Text "text/plain" For Image :"image/jpeg“ , "image/bmp“ ,"image/gif“ , "image/jpg“ ,"image/png" For Video: "video/wav“, "video/mp4" mailto:java-net@java.sun.com news:comp.lang.java For Text "text/plain" For Image "image/jpeg" "image/bmp" "image/gif" "image/jpg" "image/png" For Video "video/wav" "video/mp4" http://www.linuxtopia.org/online_books/android/devguide/guide/topics/intents/intents-filters.html

Action/Data Pair & Description Intent Filters- Data 2 Some examples of Action/Data Pair Sr.No. Action/Data Pair & Description 1 ACTION_VIEW content://contacts/people/1 Display information about the person whose identifier is "1". 2 ACTION_DIAL content://contacts/people/1 Display the phone dialer with the person filled in. 3 ACTION_VIEW tel:123 Display the phone dialer with the given number filled in. 4 ACTION_DIAL tel:123 5 ACTION_EDIT content://contacts/people/1 Edit information about the person whose identifier is "1". For Text "text/plain" For Image "image/jpeg" "image/bmp" "image/gif" "image/jpg" "image/png" For Video "video/wav" "video/mp4" <intent-filter . . . > <data android:type="video/mpeg" android:scheme="http" . . . /> <data android:type="audio/mpeg" android:scheme="http" . . . /> . . . </intent-filter>

Intent Filters- Category The Intent class defines several category constants, including these (More than 29 category): Constant Meaning CATEGORY_BROWSABLE The target activity can be safely invoked by the browser to display data referenced by a link — for example, an image or an e-mail message. CATEGORY_DEFAULT Set if the activity should be an option for the default action (center press) to perform on a piece of data. CATEGORY_APP_MAPS Used with ACTION_MAIN to launch the maps application. CATEGORY_LAUNCHER an activity on the top of stack, whenever application will start, the activity containing this category will be opened first.. https://www.tutorialspoint.com/android/android_intent_standard_categories.htm

Intent Filters- Extras This will be in KEY-VALUE PAIRS for additional information that should be delivered to the component handling the intent. The extras can be set and read using the putExtras() and getExtras() methods respectively (More than 26 Extras): For examples : EXTRA_EMAIL: A String[] holding e-mail addresses that should be delivered to. EXTRA_HTML_TEXT: A constant String that is associated with the Intent, used with ACTION_SEND to supply an alternative to EXTRA_TEXT as HTML formatted text. Intent i=new Intent(context,SendMessage.class); i.putExtra("id", user.getUserAccountId()+""); i.putExtra("name", user.getUserFullName()); context.startActivity(i); https://www.tutorialspoint.com/android/android_intent_standard_extra_data.htm

Intent Filters- Flags 1 Flags defined in the Intent class that function as metadata for the intent. The flags may instruct the Android system how to launch an activity and how to treat it after it’s launched. (More than 33 Flags): FLAG_ACTIVITY_CLEAR_TASK - Clear any existing tasks on this stack before starting the activity. FLAG_ACTIVITY_NEW_TASK - Start the activity in a new task or reuse an existing task tied to that activity. Intent i=new Intent(this, Sample.class); i.setFlags(Intent. FLAG_ACTIVITY_NEW_TASK); startActivity(i); https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en

Intent Filters- Flags 2 How FLAG_ACTIVITY_NEW_TASK work: With normal intent StartActivity With FLAG_ACTIVITY_NEW_TASK: https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en

Important Questions? Define Android intents? Ans : Slide 2 Mention mainly used of Android intents ? Ans : Slide 3 Explain the Types of Android Intents? Ans : Slide 4,5 Give Three examples of using Android Intents as : Ans : Slide 6 Use explicit intents? Use implicit intent? What are the elements of intent filter list them with short definition ? Ans : Slide 7 Give Three intent Action filter name and goal when apply on: Activity? Ans : Slide 8 Broadcast Receiver? Ans : Slide 9 Define Data intent filter and Explain (URL or MIME ) with example? Ans : Slide 7,10 What is Category intent filter end explain only Two type of it? Ans : Slide 7,12 Explain Extras intent filter and write sample java code to implement it ? Ans : Slide 7, 13 Explain Flags intent filter and write sample java code to implement it ? Ans : Slide 7,14

Questions? Discussion?