Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Android share pictures and text content

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report