Mobile Programming Pertemuan 6 Presented by Mulyono Poltek NSC Surabaya.

Slides:



Advertisements
Similar presentations
Application Fundamentals Android Development. Announcements Posting in D2L Tutorials.
Advertisements

Programming with Android: Activities and Intents Luca Bedogni Marco Di Felice Dipartimento di Informatica – Scienza e Ingegneria Università di Bologna.
Cosc 5/4730 Android Services. What is a service? From android developer web pages: Most confusion about the Service class actually revolves around what.
Intents.
Permissions.  Applications can protect resources & data with permissions  Applications statically declare permissions  Required of components interacting.
Android 101 Application Fundamentals January 29, 2010.
Intent An Intent describes the operation to be performed. Intents are used to start an activity using either of the following methods – Context.startActivity()
@2011 Mihail L. Sichitiu1 Android Introduction Application Fundamentals.
Android Security Enforcement and Refinement. Android Applications --- Example Example of location-sensitive social networking application for mobile phones.
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming.
Java RMI Project and Android Architecture
Understanding Android Security Yinshu Wu William Enck, Machigar Ongtang, and PatrickMcDaniel Pennsylvania State University.
박 종 혁 컴퓨터 보안 및 운영체제 연구실 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.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
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,
Cosc 5/4730 Introduction: Threads, Android Activities, and MVC.
Rajab Davudov. Agenda Eclipse, ADT and Android SDK APK file Fundamentals – Activity – Service – Content Provider – Broadcast Receiver – Intent Hello World.
Using Intents to Broadcast Events Intents Can be used to broadcast messages anonymously Between components via the sendBroadcast method As a result Broadcast.
Cosc 5/4730 Broadcast Receiver. Broadcast receiver A broadcast receiver (short receiver) – is an Android component which allows you to register for system.
COMP 365 Android Development.  Perform operations in the background  Services do not have a user interface (UI)  Can run without appearing on screen.
Erika Chin Adrienne Porter Felt Kate Greenwood David Wagner University of California Berkeley MobiSys 2011.
CS378 - Mobile Computing Intents.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
Frank Xu Gannon University.  Linear Layout  Relative Layout  Table Layout.
Android for Java Developers Denver Java Users Group Jan 11, Mike
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.
© 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.
ANDROID L. Grewe Components  Java Standard Development Kit (JDK) (download) (latest version)  AndroidStudio.
Android System Security Xinming Ou. Android System Basics An open-source operating system for mobile devices (AOSP, led by Google) – Consists of a base.
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
DKU-MUST Mobile ICT Education Center 10. Activity and Intent.
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) (
Introducing Intents Intents Bind application components and navigate between them Transform device into collection of interconnected systems Creating a.
Android Intents Nasrullah. Using the application context You use the application context to access settings and resources shared across multiple activity.
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android.
Lecture 2: Android Concepts
Speech Service & client(Activity) 오지영.
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
6/12/2016 TOPS Technologies- Android training -
Services. What is a Service? A Service is not a separate process. A Service is not a thread. A Service itself is actually very simple, providing two main.
The Ingredients of Android Applications. A simple application in a process In a classical programming environment, the OS would load the program code.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Putting together the AndroidManifest.xml file Creating multiple.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
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
Lecture 2: Android Concepts
Android 01: Fundamentals
CS371m - Mobile Computing Services and Broadcast Receivers
Reactive Android Development
Instructor: Mazhar Hussain
Android System Security
Activities and Intents
Android Application Development android.cs.uchicago.edu
Android Programming Lecture 9
CS371m - Mobile Computing Intents.
Application Fundamentals
Activities and Intents
Activities and Intents
Android Developer Fundamentals V2 Lesson 5
It is used to Start an Activity Start a Service Deliver a Broadcast
Introduction to Android
Lecture 2: Android Concepts
Presentation transcript:

Mobile Programming Pertemuan 6 Presented by Mulyono Poltek NSC Surabaya

Intent Three of the core components of an application are: Activities Services Broadcast Receivers They are activated through messages, called intents. Intent messaging is a facility for late runtime binding between components in the same or different applications. An Intent object, is a passive data structure holding an abstract description of an operation to be performed — or, often in the case of broadcasts, a description of something that has happened and is being announced.

There are separate mechanisms for delivering intents to each type of component: - An Intent object is passed to Context.startActivity() or Activity.startActivityForResult() to launch an activity or get an existing activity to do something new. (It can also be passed to Activity.setResult() to return information to the activity that called startActivityForResult().) - An Intent object is passed to Context.startService() to initiate a service or deliver new instructions to an ongoing service. Similarly, an intent can be passed to Context.bindService() to establish a connection between the calling component and a target service. It can optionally initiate the service if it's not already running. - Intent objects passed to any of the broadcast methods (such as Context.sendBroadcast(), Context.sendOrderedBroadcast(), or Context.sendStickyBroadcast()) are delivered to all interested broadcast receivers. Many kinds of broadcasts originate in system code. - Intent are really useful with Android Service to exchange information and notification between the calling object and the Service.

Intent Filter To inform the system which implicit intents they can handle, activities, services, and broadcast receivers can have one or more intent filters. Each filter describes a capability of the component, a set of intents that the component is willing to receive. It, in effect, filters in intents of a desired type, while filtering out unwanted intents — but only unwanted implicit intents (those that don't name a target class). An explicit intent is always delivered to its target, no matter what it contains; the filter is not consulted. An implicit intent is delivered to a component only if it can pass through one of the component's filters. An intent filter is an instance of the IntentFilter class. However, since the Android system must know about the capabilities of a component before it can launch that component, intent filters are generally not set up in Java code, but in the application's manifest file (AndroidManifest.xml) as elements. (The one exception would be filters for broadcast receivers that are registered dynamically by calling Context.registerReceiver(); they are directly created as IntentFilter objects.)

3 fundamental use-cases To start an activity: An Activity represents a single screen in an app. You can start a new instance of an Activity by passing an Intent to startActivity(). The Intent describes the activity to start and carries any necessary data. To start a service: A Service is a component that performs operations in the background without a user interface. You can start a service to perform a one-time operation (such as download a file) by passing an Intent to startService(). The Intent describes the service to start and carries any necessary data. To deliver a broadcast: A broadcast is a message that any app can receive. The system delivers various broadcasts for system events, such as when the system boots up or the device starts charging. You can deliver a broadcast to other apps by passing an Intent to sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast().

Intent Types Explicit intents specify the component to start by name (the fully-qualified class name). You'll typically use an explicit intent to start a component in your own app, because you know the class name of the activity or service you want to start. For example, start a new activity in response to a user action or start a service to download a file in the background. Implicit intents do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it. For example, if you want to show the user a location on a map, you can use an implicit intent to request that another capable app show a specified location on a map.

Explicit Intent Intent downloadIntent = new Intent(this, DownloadService.class); downloadIntent.setData(Uri.parse(fileUrl)); startService(downloadIntent);

Implicit Intent // Create the text message with a string Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage); sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type // Verify that the intent will resolve to an activity if (sendIntent.resolveActivity(getPackageManager()) != null) { startActivity(sendIntent); }