When the user is on the System album, click Share. Through our own app. Share this picture.
1. Registration
Mainly in the Androidmanifest.xml, the activity register Intent-filter. Such as:
<activity android:name= ". UI. MyActivity "> <intent-filter> <action android:name=" Android.intent.action.SEND "/> <category android:name= "Android.intent.category.DEFAULT"/> <data android:mimetype= "image/*"/> </intent-filter> <intent-filter> <action android:name= "Android.intent.action.SEND"/ > <category android:name= "Android.intent.category.DEFAULT"/> <data android:mimetype= "text/ Plain "/> </intent-filter> <intent-filter> <action android:name=" Android.intent.action.SEND_MULTIPLE "/> <category android:name=" Android.intent.category.DEFAULT "/> <data android:mimetype= "image/*"/> </intent-filter></activity>
2. Handling:
In activity, get the text and pictures in intent.
void OnCreate (Bundle savedinstancestate) {...//Get intent, action and MIME type Intent intent = getintent (); String action = Intent.getaction (); String type = Intent.gettype (); if (Intent.ACTION_SEND.equals (ACTION) && type! = null) {if ("Text/plain". Equals (type)) {handle SendText (Intent); Handle text being sent} else if (Type.startswith ("image/")) {handlesendimage (intent);//Handle Sin GLE image being sent}} else if (Intent.ACTION_SEND_MULTIPLE.equals (ACTION) && type! = null) {i F (Type.startswith ("image/")) {handlesendmultipleimages (intent);//Handle multiple images being sent} } else {//Handle other intents, such as being started from the home screen} ...} void Handlesendtext (Intent Intent) {String Sharedtext = Intent.getstringextra (Intent.extra_text); if (sharedtext! = null) {//Update UI to reflect text being shared}}void HandlEsendimage (Intent Intent) {uri Imageuri = (URI) Intent.getparcelableextra (Intent.extra_stream); if (Imageuri! = null) {//Update UI to reflect image being shared}}void handlesendmultipleimages (Intent Intent ) {arraylist<uri> Imageuris = Intent.getparcelablearraylistextra (Intent.extra_stream); if (Imageuris! = null) {//Update UI to reflect multiple images being shared}}
Many other readings:
Simple example: http://code.tutsplus.com/tutorials/android-sdk-receiving-data-from-the-send-intent--mobile-14878
Many other exchanges. Android Development Alliance QQ Group:272209595
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Android:receiving Data from the Send Intent, share your app registration system