你可以共享下面的代码:
String shareBody = "Here is the share content body";
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_using)));
所以你的全部代码(图片+文本)需要变成
private Uri imageUri; private Intent intent; imageUri = Uri.parse("android.resource://" + getPackageName() + "/drawable/" + "ic_launcher"); intent = new Intent(Intent.ACTION_SEND); //text intent.putExtra(Intent.EXTRA_TEXT, "Hello"); //image intent.putExtra(Intent.EXTRA_STREAM, imageUri); //type of things intent.setType("*/*"); //sending startActivity(intent);
把image/*替换成 with */*
更新:
Uri imageUri = Uri.parse("android.resource://" + getPackageName() + "/drawable/" + "ic_launcher"); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello"); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); shareIntent.setType("image/jpeg"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(shareIntent, "send"));
原文地址:http://www.itmmd.com/201411/214.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。
如何在android开发使用ACTION_SEND中共享图片和文本
原文地址:http://blog.csdn.net/androidmylove/article/details/42174603