Reprinted from: Http://orgcent.com/android-app-intent-share-list/ | radish cabbage blog
In the Android system, how does one add the sharing function to an application and add the application to the system sharing selection list?
Intent. createchooser ()Method to bring up the system share list.
Check whether the corresponding intent component exists. You can check android to determine whether intent exists and whether intent is available.
1. added the sharing Function for applications.
1 2 3 4 5 6 7 |
Public Static Void Sharetext ( Context Context, String Title, String Text ) { Intent intent= New Intent ( Intent. Action_send ) ; Intent. Settype ( "Text/plain" ) ; Intent. Putextra ( Intent. Extra_subject , Title ) ; Intent. Putextra ( Intent. Extra_text , Text ) ; Context. Startactivity ( Intent. Createchooser ( Intent, title ) ) ; } |
PS: aboveCodeFor text sharing, if you want to share image information, set settype to "image/*" and pass a parameter intent. extra_stream Of The URI type.
2. Add an application to the system share list
You only need to add the following code to androidmanifest. xml:
1 2 3 4 5 6 7 |
<Activity Android: Name=". Sharepage" Android: Label="Share on Weibo"> <Intent-Filter> <Action Android: Name="Android. Intent. Action. Send" /> <Category Android: Name="Android. Intent. Category. Default" /> <Data Android: mimetype="Image /*" /> </Intent-Filter> </Activity> |