Android uses the system intent for sharing and adds applications to the sharing list.

Source: Internet
Author: User
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>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.