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

1 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" + "\n\n" +"https://play.google.com/app/com.example.example");
startActivity(Intent.createChooser(sharingIntent, "select app ..."));
Run Code Online (Sandbox Code Playgroud)

但在这段代码中,我只能分享不共享图片的文字!我想分享文字和图片.

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

我如何分享文字和图片?

Dhi*_*mba 5

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

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"));
Run Code Online (Sandbox Code Playgroud)