Lec 04 Intents and Bundles Fragments. Activated by Intents Activities Services Broadcast Receivers (aka Receivers) (http://developer.android.com/guide/componen.

Slides:



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

Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
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.
 An archive file marked by an.apk suffix.  Java code + any data +resource files  is bundled by the aapt tool into an aapt tool ◦ Android Asset Packaging.
Intents.
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
Android and Project Structure. Android Android OS – Built on Linux Kernel – Phones – Netbooks – Readers – Other???
Communication in Distributed Systems –Part 2
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()
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming.
Android Middleware Bo Pang
Lecture 3 agenda Layouts Intents (both explicit and implicit) ListViews and Adapters.
박 종 혁 컴퓨터 보안 및 운영체제 연구실 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.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
Lec 04 Content Providers Adapters CursorLoaders Advanced Debugging.
Rajab Davudov. Agenda Eclipse, ADT and Android SDK APK file Fundamentals – Activity – Service – Content Provider – Broadcast Receiver – Intent Hello World.
Intent Android Club Agenda Intent class Explicit activation Implicit activation.
Erika Chin Adrienne Porter Felt Kate Greenwood David Wagner University of California Berkeley MobiSys 2011.
CS378 - Mobile Computing Intents.
Android for Java Developers Denver Java Users Group Jan 11, Mike
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
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.
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
Linking Activities using Intents How to navigate between Android Activities 1Linking Activities using Intents.
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.
Introducing Intents Intents Bind application components and navigate between them Transform device into collection of interconnected systems Creating a.
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
Activities and Intents Chapter 3 1. Objectives Explore an activity’s lifecycle Learn about saving and restoring an activity Understand intents and how.
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
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.
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
More Security and Programming Language Work on SmartPhones
Mobile Applications (Android Programming)
Lecture 2: Android Concepts
Android 01: Fundamentals
Programming with Android:
Linking Activities using Intents
Reactive Android Development
Lecture 3 agenda A tour of Android studio features
MAD.
Activities and Intents
CS371m - Mobile Computing Intents.
Android Programming Lecture 5
Application Development A Tutorial Driven Course
Activities and Intents
Android Topics What are Intents? Implicit Intents vs. Explicit Intents
Activities and Intents
It is used to Start an Activity Start a Service Deliver a Broadcast
Lecture 4 agenda Event Handling Fragments The Freemason Conspiracy
Lecture 2: Android Concepts
Mobile Programming Dr. Mohsin Ali Memon.
Android Development Tools
Presentation transcript:

lec 04 Intents and Bundles Fragments

Activated by Intents Activities Services Broadcast Receivers (aka Receivers) ( ts/intents-filters.html)

Intent Architecture / /Explicit; all you need is the packageContext and the target class Intent itn = new Intent(this, ResultActivity.class); ResultActivit y.class Explicit

Intent Architecture / /Explicit; all you need is the packageContext and the target class Intent itn = new Intent(this, ResultActivity.class); itn.putExtra(QuizActivity.CORRECT, mCorrect); itn.putExtra(QuizActivity.INCORRECT, mIncorrect); itn.putExtra(QuizActivity.NAME, mName); CORRECT: 5 INCORRECT: 3 PLAYER: Adam ResultActivit y.class Explicit

Intent Architecture::Action/Data/etc / /Explicit; all you need is the ComponentName and optionally the bundle. //Implicit; usually Action/Data and then optionally the bundle. name : Adam Gerber ret : something... Action Data Scheme Categories ComponentName Explicit Implicit

ADB (Android Device Bridge) adb kill-server adb start-server adb get-state adb devices Use kill-server / start-server to reboot the adb if your device/emulator is not communicating with your dev-machine.

Explicit Intents: intra-app call by name //******************************** //This method works great for intra-app calls between activities //******************************** //use the calling class and the called class as params to constructor. Intent itn = new Intent(this, Second.class); startActivity(itn); //******************************** //You can use this method as well //notice that all you need is the component name for explicit // calls //******************************** //instantiate with zero params and add the component this way Intent itn = new Intent(); itn.setComponent(new ComponentName("edu.uchicago.cs", "edu.uchicago.cs.Second")); startActivity(itn);

Explicit Intents: intra-app call by name // this is inside the another method, such as the onClick method Intent itnThird = new Intent(); itnThird.setComponent(new ComponentName("edu.uchicago.cs", "edu.uchicago.cs.Third")); //******************************** // or you could do this -> Intent itnThird = new Intent(this, Third.class); //******************************** itnThird.putExtra("name", "Adam Gerber"); itnThird.putExtra(" ", startActivity(itnThird);

Implicit Intents: inter-app call Intent itn = new Intent(Intent.ACTION_VIEW, Uri.parse(" startActivity(itn); Implicit intents are anonymous and loosely-coupled. You request the component like a service of the operating system.

Implicit Intents: Action/Data pairs ACTION_VIEW content://contacts/people/1 -- Display information about the person whose identifier is "1". ACTION_DIAL content://contacts/people/1 -- Display the phone dialer with the person filled in. ACTION_VIEW tel: Display the phone dialer with the given number filled in. Note how the VIEW action does what what is considered the most reasonable thing for a particular URI. ACTION_DIAL tel: Display the phone dialer with the given number filled in. ACTION_EDIT content://contacts/people/1 -- Edit information about the person whose identifier is "1". ACTION_VIEW content://contacts/people/ -- Display a list of people, which the user can browse through. This example is a typical top-level entry into the Contacts application, showing you the list of people.

Intent Architecture::Bundle (aka extras) //The bundle is a data structure inside the Intent. //It holds key/value pairs. //You can use predefined keys as well. //If you don't place the extras in there name : Adam Gerber ret : something... Action Data Scheme Categories ComponentNa me

Intents Intent messaging is a facility for late run-time binding between components in the same or different applications. Intents are handled by the Android OS. In order for the OS to know about a component, it must be declared in the application manifest file. If a component does not define Intent filters, it can only be called by explicit Intents. A component with filters can receive both explicit and implicit intents. 6/12/12

AndroidManifest.xml file Is an inventory of all the components in an application. If the component is not listed there, the Android OS won't know it's there. Not even intra-app component communication will resolve. 6/12/12

Android OS M S A *A I M A R CP

Intent Filters::Two purposes 1/ inventory of components used by the OS that are callable given certain criteria. 2/ filter requests. You can define from course to fine Beware, there is a slight mis-matching between the java and xml: ACTION_WEB_SEARCH corresponds to android.intent.action.WEB_SEARCH ACTION_EDIT corresponds to android.intent.action.EDIT CATEGORY_BROWSABLE corresonds to android.intent.category.BROWSABLE

Categories //Use Categories to further refine your Intent //Most important is CATEGORY_DEFAULT

From Google: An Intent object is a bundle of information. It contains information of interest to the component that receives the intent (such as the action to be taken and the data to act on) plus information of interest to the Android system (such as the category of component that should handle the intent and instructions on how to launch a target activity)

Only three aspects of an Intent object are consulted when the object is tested against an intent filter: >action >data (both URI and data type) >category must pass all three tests. A component can have multiple intent filters. a filter must contain at least one element, or it will block all intents

Adapters

AdapterViews