Android developers use ACTION_SEND to perfectly share images and text instances

Source: Internet
Author: User

I want to use action_send share picture + text, I run the following code, temporarily can only share pictures, can't share text, how can I share?

The code is as follows Copy Code
Private Uri Imageuri;
Private Intent Intent;

Imageuri = Uri.parse ("android.resource://" + getpackagename ()
+ "/drawable/" + "Ic_launcher");
Intent = new Intent ();
Intent.setaction (Intent.action_send);
Intent.putextra (Intent.extra_text, "Hello");
Intent.putextra (Intent.extra_stream, Imageuri);
Intent.settype ("image/*");
StartActivity (Intent);


How can I share pictures?
Processing methods

You can share the following code:

The code is as follows Copy Code
String Sharebody = "This is the share content body";
Intent sharingintent = new Intent (Android.content.Intent.ACTION_SEND);
Sharingintent.settype ("Text/plain");
Sharingintent.putextra (Android.content.Intent.EXTRA_SUBJECT, "SUBJECT here");
Sharingintent.putextra (Android.content.Intent.EXTRA_TEXT, sharebody);
StartActivity (Intent.createchooser (Sharingintent, Getresources (). getString (r.string.share_using)));


So all your code (picture + text) needs to become

  code is as follows copy code
private Uri Imageuri;
Private Intent Intent;
 
Imageuri = Uri.parse ("android.resource://" + getpackagename ()
+ "/drawable/" + "Ic_launcher");
&n Bsp
Intent = new Intent (intent.action_send);
//text
Intent.putextra (intent.extra_text, "Hello");
//image
Intent.putextra (Intent.extra_stream, Imageuri);
//type of Things
Intent.settype ("*/*");
//sending
StartActivity (intent);

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.