This article tells the story of sharing pictures and text content on the Android version of Intent.ACTION_SEND. Share it for your reference, as follows:
Editor's recommendation: Rare Earth Nuggets, this is an application for technology developers. You can obtain the latest and best technical information on Nuggets. Not only Android knowledge, front-end, back-end, and even products and designs, friends who want to become full-stack engineers should not miss it!
The following method can only implement ordinary text sharing:
private void shareContent() { Intent share = new Intent(.ACTION_SEND); ("text/plain"); String title = "title"; String extraText="Introduce a good website to you,"; (Intent.EXTRA_TEXT, extraText); if (title != null) { (Intent.EXTRA_SUBJECT, title); } startActivity((share, "Share it")); }
Then if I want to share pictures and text on Sina Weibo at the same time, then use the following method:
private void share(String content, Uri uri){ Intent shareIntent = new Intent(Intent.ACTION_SEND); if(uri!=null){ (Intent.EXTRA_STREAM, uri); ("image/*"); // When the user selects a text message, use sms_body to get the text ("sms_body", content); }else{ ("text/plain"); } (Intent.EXTRA_TEXT, content); //Customize the title of the selection box startActivity((shareIntent, "Invite friends")); //The default title of the system }
The reason why this method can pass pictures is because ("image/*"), and setType("image/*") can pass text or picture; the content of the picture can be specified by Uri, please note that the url of the picture needs to be converted into uri.
The above is the entire content of this article. I hope that the content of this article has a certain reference value for everyone's study or work. If you have any questions, you can leave a message to communicate. Thank you for your support.