Android 调用系统内置分享
来源:互联网 发布:约瑟夫环 知乎 编辑:程序博客网 时间:2024/05/11 17:58
保存后的图片最后都是要分享, 常见的分享平台有QQ 微博 微信等等, 它们都提供各自的api, 我们可以集成到项目里面, 但是每个平台都要集成appkey等等,当然可以把他们都封装起来, 不过也得用上2天, 这里提供一下系统的内置分享方式,快速方便:
先来个图:
代码:
/** * * 分享单张图片 * * @param context * 上下文 * @param activityTitle * @param msgTitle * 消息标题 * @param msgText * 消息内容 * @param imgPath * 图片路径 * */ public static void shareMsg(Context context, String activityTitle, String msgTitle, String msgText, String imgPath) { Intent intent = new Intent(Intent.ACTION_SEND); if (imgPath == null || imgPath.equals("")) { intent.setType("text/plain"); // 纯文本 } else { File f = new File(imgPath); if (f != null && f.exists() && f.isFile()) { intent.setType("image/jpg"); Uri u = Uri.fromFile(f); intent.putExtra(Intent.EXTRA_STREAM, u); } } intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle); intent.putExtra(Intent.EXTRA_TEXT, msgText); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(Intent.createChooser(intent, activityTitle)); }
bingo!
0 0
- Android 调用系统内置分享
- 调用系统分享 Android
- Android调用系统分享
- android调用系统分享
- android 简单调用 系统分享
- Android:调用系统分享功能
- Android:调用系统分享功能
- Android:调用系统分享功能
- 关于调用Android系统分享
- Android之调用系统分享
- android 调用系统中分享功能
- android调用系统的分享接口
- 探索Android调用系统的分享功能
- Android调用系统本身的分享功能
- Android 调用系统的分享功能
- 探索Android调用系统的分享功能
- android 调用系统分享功能以及实现自定义分享
- Android调用系统分享,指定某些应用来分享
- 线性代数
- Linux编译安装中configure、make和make install各自的作用
- NSJSONSerialization-JSON数据与NSDictionary和NSArray之间的转化
- 28. SpringBoot启动时的Banner设置【从零开始学Spring Boot】
- 类别(Category)的作用(一)---将实现分散到不同文件
- Android 调用系统内置分享
- Scala数组操作
- ssh
- python字符串比较
- Leetcode 24 :Swap Nodes in Pairs
- 小米架构师:亿级大数据实时分析与工具选型(附PPT)
- linux下自动化部署apache + php环境
- 20160712梅西法&科利法.md
- 果然咸鱼还是一如既往的咸鱼