Open Intents - Android Intents Mechanism and Dependency Management

21
www.openintents.org [email protected] FOSDEM, February 6, 2010 Open Intents Android Intents Mechanism Friedger Müffke @fmdroid #openintents

description

Presentation about Android's Intent system, the intent registry from OpenIntents as well as the dependency manager currently developed.

Transcript of Open Intents - Android Intents Mechanism and Dependency Management

Page 1: 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

Page 2: Open Intents - Android Intents Mechanism and Dependency Management

Outline

● Android intents and intents filter

● OpenIntents

● Dependency and intents manager

Page 3: Open Intents - Android Intents Mechanism and Dependency Management

Android Platform

Page 4: Open Intents - Android Intents Mechanism and Dependency Management

No monoliths ..

but interconnectedcomponents

All apps are equal!

Page 5: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 6: Open Intents - Android Intents Mechanism and Dependency Management

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)

Page 7: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 8: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 9: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 10: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 11: Open Intents - Android Intents Mechanism and Dependency Management

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>

Page 12: Open Intents - Android Intents Mechanism and Dependency Management

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);

Page 13: Open Intents - Android Intents Mechanism and Dependency Management

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!

Page 14: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 15: Open Intents - Android Intents Mechanism and Dependency Management

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:

Page 16: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 17: Open Intents - Android Intents Mechanism and Dependency Management

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!

Page 18: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 19: Open Intents - Android Intents Mechanism and Dependency Management

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.

Page 20: Open Intents - Android Intents Mechanism and Dependency Management

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

Page 21: Open Intents - Android Intents Mechanism and Dependency Management

More info

Web site: www.openintents.org

Developer group: http://groups.google.com/group/openintentsCode repository: http://openintents.googlecode.comTwitter: http://twitter.com/openintents