您好我想分享图片和文字一起使用以下代码,但它只是共享图片,文字没有被分享,
private void shareIntent(){
String imagePath = Environment.getExternalStorageDirectory()
+ "/logo.jpg";
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "www.google.co.in");
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
startActivity(Intent.createChooser(sharingIntent, "Share Image!"));
}
我如何分享文字和图片?请帮忙。
答案 0 :(得分:0)
private void shareIntent(){
String imagePath = Environment.getExternalStorageDirectory()
+ "/logo.jpg";
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "www.google.co.in");
sharingIntent.putExtra(Intent.EXTRA_TITLE, "www.google.co.in");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
startActivity(Intent.createChooser(sharingIntent, "Share Image!"));
}
答案 1 :(得分:0)
private void initShareIntent(String _text)
{
File filePath = getFileStreamPath("shareimage.jpg"); //optional //internal storage
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, _text);
shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath.toString())));
//optional//use this when you want to send an image
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
}