如何在Android中使用共享意图共享图像+文本 [英] How to Share Image+Text using Share Intent in android
本文介绍了如何在Android中使用共享意图共享图像+文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了这段代码,但是无法正常工作.
I use this code, but its not working properly.
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中不起作用.
When I use the type text, then it works properly.
But I want to share a text and an image.
And the share intent is not working in 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"));
这篇关于如何在Android中使用共享意图共享图像+文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文