Open Intents - Android Intents Mechanism and Dependency Management
-
Upload
friedger-mueffke -
Category
Technology
-
view
5.639 -
download
0
description
Transcript of Open Intents - Android Intents Mechanism and Dependency Management
www.openintents.org [email protected] FOSDEM, February 6, 2010
Open IntentsAndroid Intents Mechanism
Friedger Müffke
@fmdroid#openintents
Outline
● Android intents and intents filter
● OpenIntents
● Dependency and intents manager
Android Platform
No monoliths ..
but interconnectedcomponents
All apps are equal!
Modular Apps
● Activity UI for one focused endeavor
● Service no UI, used for long running processes
● Broadcast receiver receives announcements
● Content provider makes data available
Intents (1)
VIEW + www.google.com
Web browser Android
VIEW + www.google.com
VIEW + Contact
VIEW + Image
DIAL + 123
PICK + Image
EDIT + Contact
SEND + Note
.....
Intents:
Intents:
Intent = Action + Data (+ Extras + Categories + Flags)
Intents (2)
● Transition and messaging between componentswithin application and beyond
● Source component + target component + data● Expected behaviour, e.g. TAKE_PICTURE● Used throughout the system● Explicit vs. implict intents
Named targetor Tests against intent filters
Intent filters (1)
● Advertising functionality of compontent
● Registered at install / start up timepart of Manifest.xml
● Define tests for implicit intents ● Multiple filters of component are ORed
Intent filters (2)● Action test
e.g. TAKE_PICTUREOne must matchIntent without action always accepted
● Data / Mime-type teste.g. content://contacts/people/1 geo:0,0?q=Pizza
image/jpeg text/htmlfilters with wildcardsmatch everything specifiedcontent: and file: schema implicitly supported
Intent filters (3)
● Category teste.g. CATEGORY_DEFAULT, CATEGORY_BROWSABLE
All categories must matchIntents for activities always include
CATEGORY_DEFAULT
● User can choose if more than one target found ● Exception if no target found
Manifest.xml<?xml version="1.0" encoding="utf-8"?> <manifest . . . > <application . . . > <activity
android:name="org.openintents.shopping.ShoppingActivity" android:icon="@drawable/small_pic.png" android:label="@string/shopping" . . . >
<intent-filter> <action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.INSERT" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType = "vnd.android.cursor.dir/vnd.openintents.shopping.item" /> </intent-filter> </activity> <service . . ./> . . . <uses-permisson . . . /> <uses-library . . . /></application> </manifest>
In Practice
e.g. in Activity
Intent i = new Intent(Intent.ACTION_VIEW);i.setData(„http://www.openintents.org“);
this.startActivity(i);this.startActivityForResult(i, RESCODE);this.startService(i);this.bindService(i, con, 0);this.sendBroadcast(i);
Benefits
● Focus on core functionality● Reuse● Exchange system components, e.g.
home screen, keyboard, address book, dialer
● Automatic handling
Tasks, plug-ins, menus, live foldersDon't forget performance and security!
OI Extensions
OI Shopping listOI Notepad
OI About
OI Delete all
OI Convert CSV
OI Voice notes
OI Safe OI File manager
OI applications work together
Create new intents
VIEW SHOW
DISPLAY
EXHIBIT
EXPOSE
REVEAL
The Tower of Babel by Pieter Brueghel the Elder (1563)
Every developer can create their own new intents:
OpenIntents.org
● Discussion group since 2007● All about open applications and interoperability● Open source● List of Android libraries● Intents registry
● Backed by OpenIntents UG (haftungsbeschränkt)– Closed source apps– Organizer of droidcon
Intent registrywww.openintents.org
Browse and findintents, actions, applications, URIs, extras
Promote your ownintents and applications
As of January 2010: >50 registered intents
Reuse components! Don't reinvent the wheel!
Dependency Manager (1)● Intents create dependencies
between components● Standard implementation:
– run-time dependency checklate binding
– nearly constantly connected– Programs handles missing components
e.g. direct user to app store or explain missing feature
Dependency Manager (2)
● Components that rely on dependent components– A la distro package managers– Light-weight, late binding still possible– Helper library– Declaration in Manifest.xml uses-intent
● Resolution helper with UI– Interface to various sources, e.g. app stores,
personal listings, etc.
droidcon 2010Brussels, Berlin
Barcelona, London
All information at droidcon.be and droidcon.deFree barcampConference
Participate as speaker, sponsor or attendeeGet in touch with Android community
and decision makersPresent and discuss ideas and results
More info
Web site: www.openintents.org
Developer group: http://groups.google.com/group/openintentsCode repository: http://openintents.googlecode.comTwitter: http://twitter.com/openintents