我想在我的应用程序中以同样的WhatsApp方式共享数据:

当我在我自己的应用程序中尝试它时,我只能得到文本("Check out...")。如何获取其余的数据:图片、标题、描述和网站地址?
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
} else if (type.startsWith("image/")) {
handleSendImage(intent); // Handle single image being sent
}
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
if (type.startsWith("image/")) {
handleSendMultipleImages(intent);
}
}我只有在EXTRA_TEXT中才能得到ACTION_SEND。
发布于 2016-11-18 21:38:27
您可以通过流式传输图像来共享图像。但这主要取决于您选择共享的应用程序是否支持图像流共享。
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(photoFile));
startActivity(Intent.createChooser(shareIntent, "Share image using"));点击此链接,了解有关共享选项的信息。
https://guides.codepath.com/android/Sharing-Content-with-Intents
要从其他应用程序接收共享数据,请选中此链接:
发布于 2017-01-04 11:56:03
我在最后这样做的方式是在后端解析链接元数据标签,并将详细信息发送到应用程序。
https://stackoverflow.com/questions/40678304
复制相似问题