Android 信息分享实现

一、短信分享

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);

你可能感兴趣的:(android,邮件,分享,短信)