Android调用系统自带的分享功能

栏目: IOS · Android · 发布时间: 4年前

分享文本信息

Intent textIntent = new Intent(Intent.ACTION_SEND);
 textIntent.setType("text/plain");
 textIntent.putExtra(Intent.EXTRA_TEXT, "这是一段分享的文字");
 startActivity(Intent.createChooser(textIntent, "分享"));

分享单张图片

String path = getResourcesUri(R.drawable.share);
Intent imageIntent = new Intent(Intent.ACTION_SEND);
imageIntent.setType("image/jpeg");
imageIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
startActivity(Intent.createChooser(imageIntent, "分享"));

分享多个文件

List<Uri> imageUris = new ArrayList<>();
Uri uri1 = Uri.parse(getResourcesUri(R.drawable.share1));
Uri uri2 = Uri.parse(getResourcesUri(R.drawable.share2));
imageUris.add(uri1);
imageUris.add(uri2);
Intent mulIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
mulIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
mulIntent.setType("image/jpeg");
startActivity(Intent.createChooser(mulIntent,"多文件分享"));

指定分享到微信

Intent intent = new Intent(Intent.ACTION_SEND);
// 分享到QQ package:com.tencent.mobileqq
intent.setPackage("com.tencent.mm");
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "分享到微信的内容");
startActivity(wechatIntent);

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

High Performance Python

High Performance Python

Micha Gorelick、Ian Ozsvald / O'Reilly Media / 2014-9-10 / USD 39.99

If you're an experienced Python programmer, High Performance Python will guide you through the various routes of code optimization. You'll learn how to use smarter algorithms and leverage peripheral t......一起来看看 《High Performance Python》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

随机密码生成器
随机密码生成器

多种字符组合密码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具