转:android 调用系统分享的类型和步骤
来源:互联网 发布:js 字段默认值 编辑:程序博客网 时间:2024/06/07 02:29
类型======
case "doc": ContentType = "application/msword"; bre
case "doc": ContentType = "application/msword"; break; case "pdf": ContentType = "application/pdf"; break; case "jpg": case "jpeg": ContentType = "image/jpeg"; break; case "gif": ContentType = "image/gif"; break; case "zip": ContentType = "application/zip"; break; case "txt": ContentType = "text/plain"; break; case "htm": case "html": ContentType = "text/html"; break; case "xls": ContentType = "application/vnd.ms-excel"; break; case "ppt": ContentType = "application/vnd.ms-powerpoint"; break; default: ContentType = "application/octet-stream"; break;
类型===========================================
标准模式=====
Intent intent = new Intent(Intent.ACTION_SEND); //启动分享发送的属性intent.setType("text/plain"); // 分享发送的数据类型String msg = "推荐给大家";intent.putExtra(Intent.EXTRA_TEXT, msg); // 分享的内容activity.startActivity(Intent.createChooser(intent,"选择分享"));// 目标应用选择对话框的标题标准模式========================================
举例说明======
1.发送文本
Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,"Mirror is a good application, let's share it"); sendIntent.setType("text/*");
startActivity(sendIntent);
2.发送图片
Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); File f = new File(Environment.getExternalStorageDirectory() + "/q.png"); Uri u = Uri.fromFile(f);
sendIntent.putExtra(Intent.EXTRA_STREAM, u);
sendIntent.setType("image/png");
startActivity(sendIntent);
举例说明========================================特例===========/** * 从Assets中读取图片 */private Bitmap getImageFromAssetsFile(String fileName) {Bitmap image = null;AssetManager am = getResources().getAssets();try {InputStream is = am.open(fileName);image = BitmapFactory.decodeStream(is);is.close();} catch (IOException e) {e.printStackTrace();}return image;}从android eclipse工程中获取图片资源注意: 调用系统默认分享,不能传工程中的图片资源,只能是再手机上存储的图片特例===============================================
0 0
- 转:android 调用系统分享的类型和步骤
- 调用系统分享 Android
- Android调用系统分享
- android调用系统分享
- android调用系统的分享功能实现分享到短信,邮件和其他
- Android 调用系统的分享[完美实现同时分享图片和文字]
- android调用系统的分享接口
- 探索Android调用系统的分享功能
- Android调用系统本身的分享功能
- Android 调用系统的分享功能
- 探索Android调用系统的分享功能
- Android调用系统分享和指定app分享-微信朋友圈图文分享和qq分享
- Android调用系统分享和指定app分享-微信朋友圈图文分享和qq分享
- Android分享---调用系统自带的分享功能
- Android 调用系统的分享界面,进行文件分享
- android 简单调用 系统分享
- Android:调用系统分享功能
- Android:调用系统分享功能
- 单例模式
- 回答为什么会叫“Bulk Gas”
- 【poj 1743】后缀数组
- Windows开机自启动程序的方法
- Protocol Buffers 语法指南
- 转:android 调用系统分享的类型和步骤
- windows系统启动流程
- Google Protocol Buffers 编码(Encoding)
- 观影坪-纪录片之《穹顶之下》
- 计算机程序的执行过程分析
- Linux运行错误:error while loading shared libraries: xxx.so.0:cannot open shared object file: No such fil
- 关于NSMutableAttributedString 的使用以及介绍
- 《实体解析与信息质量》-1.2.4.实体身份管理
- mysql 年龄查询