Android Development share simple data (top)

Source: Internet
Author: User

Share text content

New Intent (); sendintent.setaction (intent.action_send); Sendintent.putextra (Intent.extra_text,"This is my TEXT To send. " ); Sendintent.settype ("Text/plain"); StartActivity (sendintent) ;

If Intent.createchooser () is called for intent, there are several benefits:

1. Even if the user has previously set the default action for this intent, the selection screen will be displayed.

2. If there is no matching program, Android displays the system information.

3. We can specify the title of the selection interface.

Just modify the last line of code to StartActivity (Intent.createchooser (Sendintent, Getresources (). GetText (r.string.send_to));

Sharing binary Content

New Intent (); shareintent.setaction (intent.action_send); Shareintent.putextra (Intent.extra_stream, uriToImage); Shareintent.settype ("Image/jpeg"); StartActivity (Intent.createchooser (shareintent,                    getresources (). GetText (r.string.send_to));

Send multiple pieces of content

New arraylist<uri>//  Add your image URIsherenew  Intent (); Shareintent.setaction (intent.action_send_multiple); Shareintent.putparcelablearraylistextra (Intent.EXTRA_STREAM , Imageuris); Shareintent.settype ("image/*""Share images to.."));

If it's a different picture format, you should use image/* to match activity that can receive any type of image.

If you need to share many different types of data, you can use */* to represent MIME

Android Development share simple data (top)

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.