Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中共享文本和图像_Android_Android Intent_Android Webview - Fatal编程技术网

如何在Android中共享文本和图像

如何在Android中共享文本和图像,android,android-intent,android-webview,Android,Android Intent,Android Webview,我想分享我的应用程序的内容(文本和图像),对于这个问题,我写了以下代码: Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("*/*"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(content) + "" +"\n\n" + "download us app from this link"

我想分享我的应用程序的内容(文本和图像),对于这个问题,我写了以下代码:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(content) + "" +"\n\n" + "download us app from this link" + "\n\n" +"https://play.google.com/app/com.example.example");
startActivity(Intent.createChooser(sharingIntent, "select app ..."));
但在这段代码中,我可以只共享文本而不共享图像!我想分享文字和图片

对于显示文本和图像,我使用
Webview
。我在
webview
中将图像显示为文本

如何共享文本和图像?

请参阅下面的代码

 Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/png");
    intent.putExtra(Intent.EXTRA_TEXT,"http://lorempixel.com/400/200/sports/1/");//your Image Url
    startActivity(Intent.createChooser(intent, "Share Image"));
参见下面的代码

 Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/png");
    intent.putExtra(Intent.EXTRA_TEXT,"http://lorempixel.com/400/200/sports/1/");//your Image Url
    startActivity(Intent.createChooser(intent, "Share Image"));

将图像的URI添加到捆绑包中(例如),这将允许在从捆绑包中取出数据时找到并使用相同的图像。

将图像的URI添加到捆绑包中(例如),这将允许在从捆绑包中取出数据时找到并使用相同的图像。

下面的代码对于与其他应用程序共享文本和图像非常有用

String imageToShare = "http://s1.dmcdn.net/hxdt6/x720-qef.jpg"; //Image You wants to share

String title = "Title to share"; //Title you wants to share

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, title);
shareIntent.setType("*/*");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_TEXT, imageToShare);
startActivity(Intent.createChooser(shareIntent, "Select App to Share Text and Image"));

下面的代码对于与其他应用程序共享文本和图像非常有用

String imageToShare = "http://s1.dmcdn.net/hxdt6/x720-qef.jpg"; //Image You wants to share

String title = "Title to share"; //Title you wants to share

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, title);
shareIntent.setType("*/*");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_TEXT, imageToShare);
startActivity(Intent.createChooser(shareIntent, "Select App to Share Text and Image"));

我想从互联网上显示图像,而不是保存它。怎么可能呢?@KirKoloft,现在我更新了我的答案,它的工作是为了我想从互联网上展示图片而不是保存它。怎么可能?@KirKoloft,现在我更新了我的答案,它对meDear的作用不适用于我…我有两个TextView和ImageUrl,但我可以将一个TextView共享给Telegrame亲爱的不适用于我…我有两个TextView和ImageUrl,但我可以将一个TextView共享给Telegrame