Get the App
SLTechnology News&Howtos  ›  Development  › 

How does Android share pictures and text content

Shulou Source: shulou.com Published: 2022-05-31 22:50:39 09月27日 Update

This article mainly introduces Android how to share pictures and text content related knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that after reading this Android how to share pictures and text content article will have a harvest, let's take a look at it.

Implement ordinary text:

Private void shareContent () {Intent share = new Intent (android.content.Intent.ACTION_SEND); share.setType ("text/plain"); String title = "title"; String extraText= "introduce a good website, www.jcodecraeer.com"; share.putExtra (Intent.EXTRA_TEXT, extraText); if (title! = null) {share.putExtra (Intent.EXTRA_SUBJECT, title);} startActivity (Intent.createChooser (share, "share");}

So 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 (urified null) {shareIntent.putExtra (Intent.EXTRA_STREAM, uri); shareIntent.setType ("image/*"); / / when users select SMS messages, use sms_body to get the text shareIntent.putExtra ("sms_body", content);} else {shareIntent.setType ("text/plain");} shareIntent.putExtra (Intent.EXTRA_TEXT, content) / / customize the title of the selection box startActivity (Intent.createChooser (shareIntent, "invite friends"); / / system default title}

The reason why this method can pass pictures, is because shareIntent.setType ("image/*"), and setType ("image/*") can pass text or pictures; where the content of the picture can be specified by Uri, note that the url of the picture needs to be converted into uri.

This is the end of the article on "how Android shares pictures and text content". Thank you for reading! I believe you all have a certain understanding of "how to share pictures and text content in Android". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Pictures text content title knowledge methods articles selection ordinary reason value at the same time picture content friends easy to operate articles easy to understand more users read Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Huawei MariaDB Shulou Information Linux