如何在android中使用Share Intent共享图像文本

前端之家收集整理的这篇文章主要介绍了如何在android中使用Share Intent共享图像文本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用此代码,但它无法正常工作.
String Body = "Deals Name: " + Bussinessname + "\n"
    + "Deals: " + deal + "\n" + "Address: " + city
    + "," + country;

Intent share = new Intent(android.content.Intent.ACTION_SEND);

Uri screenshotUri = Uri.parse(Images.Media.EXTERNAL_CONTENT_URI + "/" + image);
share.setType("image/*");
share.putExtra(Intent.EXTRA_SUBJECT,"The EssexPass");
share.putExtra(Intent.EXTRA_TEXT,Body);
share.putExtra(Intent.EXTRA_STREAM,screenshotUri);
startActivity(Intent.createChooser(share,"Share Deal"));

当我使用类型文本时,它可以正常工作.
但我想分享一个文字和一个图像.
并且共享意图在FaceBook中不起作用.

解决方法

试试下面的代码
String fileName = "image-3116.jpg";//Name of an image
String externalStorageDirectory = Environment.getExternalStorageDirectory().toString();
String myDir = externalStorageDirectory + "/saved_images/"; // the file will be in saved_images
Uri uri = Uri.parse("file:///" + myDir + fileName);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/html");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Mail");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Launcher");
shareIntent.putExtra(Intent.EXTRA_STREAM,uri);
startActivity(Intent.createChooser(shareIntent,"Share Deal"));
原文链接:https://www.f2er.com/android/317055.html

猜你在找的Android相关文章