How to share pictures and text in Android development using Action_send

Source: Internet
Author: User

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

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 a picture?

Processing methods

You can share the following code:

String Sharebody = "Here 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

Private Uri imageuri;private Intent Intent; Imageuri = Uri.parse ("android.resource://" + getpackagename () + "/drawable/" + "Ic_launcher"); Intent = new Intent (intent.action_send);//textintent.putextra (Intent.extra_text, "Hello");//imageintent.putextra ( Intent.extra_stream, Imageuri);//type of Thingsintent.settype ("*/*");//sendingstartactivity (Intent);


Replace the image/* with */*

Update:

Uri Imageuri = Uri.parse ("android.resource://" + getpackagename () + "/drawable/" + "Ic_launcher"); Intent shareintent = new Intent (); shareintent.setaction (intent.action_send); Shareintent.putextra (Intent.extra_text, "Hello"); Shareintent.putextra (Intent.extra_stream, Imageuri); Shareintent.settype ("Image/jpeg"); ShareIntent.addFlags ( intent.flag_grant_read_uri_permission); StartActivity (Intent.createchooser (shareintent, "send"));


Original address: http://www.itmmd.com/201411/214.html
This article by Meng Meng's IT person to organize the release, reprint must indicate the source.

How to share pictures and text in Android development using Action_send

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.