3. What's this all about?
Android offers a lot of opportunities to integrate
with other apps → use them!
●
use functionality provided by other apps
●
provide functionality other apps can use
DevFest Berlin 2013
3
5. What are Intents again?
●
„An intent is an abstract description of an
operation to be performed.“
→ stores data that is interpreted by others
●
Contains:
–
Action
–
Data (URI)
–
Type
–
Extras („simple“ data types)
DevFest Berlin 2013
5
6. Activity
●
●
„An activity is a single, focused thing that the
user can do.“
You can start activities of other apps
–
startActivity(Intent)
–
startActivityForResult(Intent, int)
DevFest Berlin 2013
6
8. Service
●
●
●
„A Service is an application component that
can perform long-running operations in the
background and does not provide a user
interface.“
Can be used for interprocess communication
(IPC) → Context.bindService()
Allows you to call exposed methods in another
app
DevFest Berlin 2013
8
11. Content provider
●
●
●
●
„Content providers are the standard interface
that connects data in one process with code
running in another process.“
Exposes structured set of data (think: table in
an SQL database)
Read and write data blobs
Notification mechanism when data has
changed
DevFest Berlin 2013
11
12. Give me your content://
●
ContentResolver is used to access a content
provider
●
Needs a content:// URI
–
–
●
Authority: specifies which content provider to use
Path: specifies what data to access
Example:
content://com.fsck.k9.messageprovider/inbox_messages
DevFest Berlin 2013
12
14. Notification mechanism
●
Be notified when data managed by the content
provider changes:
ContentResolver.registerContentObserver()
●
Notify when data was changed:
ContentResolver.notifyChange(Uri, …)
DevFest Berlin 2013
14
16. Broadcast receiver
●
Receives Intents broadcasted via
Context.sendBroadcast()
●
Examples:
–
SMS received
–
Time changed
–
Boot complete
–
Connectivity change
–
Email received
DevFest Berlin 2013
16
17. Finding components to talk to
●
Use PackageManager.queryIntent*()
●
<intent-filter>
●
<meta-data>
<service android:name=".FancyService">
<intent-filter>…</intent-filter>
<meta-data android:name="protocolVersion"
android:value="1"/>
<meta-data android:name="settingsActivity"
android:value="com.example.app.SettingsActivity"/>
</service>
DevFest Berlin 2013
17
18. Important
●
●
Protect components exposing sensitive data
using Android permissions
It's a public API!
–
–
●
Use versioning
If you make a mistake not only your app will break
Make sure you read the official documentation
when adding support for standard intent
actions*
DevFest Berlin 2013
18
19. Summary
●
●
●
●
Expose an Activity to provide some
functionality requiring an user interface
Use a Service to allow performing
(background) actions
Allow others to read/write your data using a
content provider
Send broadcast intents to notify others of
important events
DevFest Berlin 2013
19
20. Take-away
Make the Android experience
more awesome by allowing
other apps to integrate with
yours
DevFest Berlin 2013
20