展会信息港展会大全

Android信息分享实现 短信分享 图片分享 邮件分享
来源:互联网   发布日期:2016-01-14 09:26:13   浏览:5848次  

导读:一、短信分享Intent intent = new Intent(Intent.ACTION_SEND);// intent.setType(text/plain); //纯文本// 图片分享intent.setType(image/png);// 添加图片File f = new File(/sdcard/sd.png......

一、短信分享

Intent intent = new Intent(Intent.ACTION_SEND);

// intent.setType("text/plain"); //纯文本

// 图片分享

intent.setType("image/png");

// 添加图片

File f = new File("/sdcard/sd.png");

Uri u = Uri.fromFile(f);

intent.putExtra(Intent.EXTRA_STREAM, u); //添加图片

intent.putExtra(Intent.EXTRA_SUBJECT, "分享");

intent.putExtra(Intent.EXTRA_TEXT, "I would like to share this with you...");

startActivity(Intent.createChooser(intent, getTitle()));

二、邮件分享

Intent log = new Intent("android.intent.action.SEND");

Object[] arrayOfObject2 = new Object[3];

arrayOfObject2[0] = "nick";

arrayOfObject2[1] = ": ";

arrayOfObject2[2] = "content";

String str1 = String.format("@%s%s %s", arrayOfObject2);

String str2 = str1 + "什么";

Object[] arrayOfObject1 = new Object[1];

arrayOfObject1[0] = str2;

log.putExtra("android.intent.extra.TEXT", getString(R.string.mail_body_text, arrayOfObject1));

log.putExtra("android.intent.extra.SUBJECT", "邮件");

log.setType("application/octet-stream");

startActivity(log);

赞助本站

人工智能实验室

相关热词: 分享

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港