Easy to share notes on Android

Source: Internet
Author: User

HTTP://BLOG.CSDN.NET/XYZ_LMN/ARTICLE/DETAILS/16856843 uses the intent implicit invoke activity method, mainly uses the Intent.action_ Send and Intent.createchooser (); Call the share interface of the Android system. The system filters the apps on the phone with the sharing app, giving the user a choice. If you do not use Intent.createchooser () then the system will be the default user sharing method, only if not set up to let the user choose. 1.simple sharing of text
1 New Intent (); 2 intent.setaction (intent.action_send); // set the action of the intent 3 Intent.putextra (Intent.extra_text, "YOUR SHARE TEXT"); // what to share tag and content 4 intent.settype ("Text/plain"); // the type of data sent by the flag for easy processing by the receiver (type/subtype) 5 startactivity (Inten); // using methods that implicitly invoke activity
    1. Methods for implicitly invoking activity
Or
    1. StartActivity (Intent.createchooser (Intent, "TheChooser dialog title");//
2.send pictures using the
    1. Intent.putextra (Intent.extra_stream, Imageuri);
    2. Intent.settype ("imag/*");//* can be jpg,png, etc.
3.You can also share a set of data at the same time
1 list<uri> URIs; 2 New Intent (); 3 intent.setaction (intent.action_sed_multiple); // Send Group 4 Intent.putparcelablearraylistextra (Intent.extra_stream, URIs); 5 intent.settype ("*/*");//If all are video videos/*6startactivity (intent);
If you want your app to go to the pop-up share list, you'll need to add intent-filter to the Mainifest:Example:
1 <Intent-filter>  2                <ActionAndroid:name= "Android.intent.action.SEND" />  3   4                <categoryAndroid:name= "Android.intent.category.DEFAULT" />  5   6                <DataAndroid:mimetype= "image/*" />  7            </Intent-filter>  8          <Intent-filter>  9                <ActionAndroid:name= "Android.intent.action.SEND" />  Ten    One                <categoryAndroid:name= "Android.intent.category.DEFAULT" />   A      -                <DataAndroid:mimetype= "Text/plain" />   -            </Intent-filter>   the            <Intent-filter>   -                <ActionAndroid:name= "Android.intent.action.SEND_MULTIPLE" />   -    -                <categoryAndroid:name= "Android.intent.category.DEFAULT" />   +    -                <DataAndroid:mimetype= "image/*" />   +            </Intent-filter>  
Received in the activity received
1 Intent Intent = getintent (); 2 String action = intent.getaction (); // corresponding intent.setaction () 3 String type = Intent.gettype (); // corresponding Intent.settype () 4 Inten.get??? Extra (Intent.extra_???) or Intent.getparcelableextra (Intent.extra_stream);

You can also put the share in the Actionbar.

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.