分享文本信息
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);
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- laravel自带用户认证
- Mac自带apache配置
- opencv自带例子学习-图像混合
- Golang中自带的强大命令工具
- 使用oracle自带的命令进行导入导出
- opencv自带例子学习-文件输入与输出
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
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》 这本书的介绍吧!