Beruflich Dokumente
Kultur Dokumente
Just as your application can send data to other applications, so too can it easily receive data from
applications. Think about how users interact with your application, and what data types you want to receive
from other applications. For example, a social networking application would likely be interested in receiving
text content, like an interesting web URL, from another app. The Google+ Android application
(https://play.google.com/store/apps/details?id=com.google.android.apps.plus) accepts both text and single or multiple
images. With this app, a user can easily start a new Google+ post with photos from the Android Gallery app.
Note: For more information on intent lters and intent resolution please read Intents and Intent Filters
(https://developer.android.com/guide/components/intents-lters.html#ifs)
When another application tries to share any of these things by constructing an intent and passing it to startActivity()
(https://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent)), your application will be
listed as an option in the intent chooser. If the user selects your application, the corresponding activity (.ui.MyActivity in the
example above) will be started. It is then up to you to handle the content appropriately within your code and UI.
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
if (type.startsWith("image/")) {
handleSendMultipleImages(intent); // Handle multiple images being sent
}
} else {
// Handle other intents, such as being started from the home screen
}
...
}
Caution: Take extra care to check the incoming data, you never know what some other application may send you. For
example, the wrong MIME type might be set, or the image being sent might be extremely large. Also, remember to process
binary data in a separate thread rather than the main ("UI") thread.
or it can be more complicated like applying an interesting photo lter to an image. It's really specic to your application what
happens next.