Android 信息分享实现
一、短信分享
01
Intent intent = new Intent(Intent.ACTION_SEND);
02
// intent.setType("text/plain"); //纯文本
03
// 图片分享
04
intent.setType("image/png");
05
// 添加图片
06
File f = new File("/sdcard/sd.png");
07
Uri u = Uri.fromFile(f);
08
intent.putExtra(Intent.EXTRA_STREAM, u); //添加图片
09
intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
10
intent.putExtra(Intent.EXTRA_TEXT, "I would like to share this with you...");
11
startActivity(Intent.createChooser(intent, getTitle()));
二、邮件分享
01
Intent log = new Intent("android.intent.action.SEND");
02
Object[] arrayOfObject2 = new Object[3];
03
arrayOfObject2[0] = "nick";
04
arrayOfObject2[1] = ": ";
05
arrayOfObject2[2] = "content";
06
String str1 = String.format("@%s%s %s", arrayOfObject2);
07
String str2 = str1 + "什么";
08
Object[] arrayOfObject1 = new Object[1];
09
arrayOfObject1[0] = str2;
10
log.putExtra("android.intent.extra.TEXT", getString(R.string.mail_body_text, arrayOfObject1));
11
log.putExtra("android.intent.extra.SUBJECT", "邮件");
12
log.setType("application/octet-stream");
13
startActivity(log);
作者:android.google
补充:移动开发 , Android ,