【发布时间】:2017-03-06 04:52:21
【问题描述】:
My Codename One 应用具有 ShareButton,其用法如下:
// Share this report on social networks (text plus screenshot)
ShareButton shareReportButton = new ShareButton();
shareReportButton.setText("Share this report!");
shareReportButton.getAllStyles().setBorder(
RoundBorder.create().rectangle(true));
FontImage.setMaterialIcon(shareReportButton, FontImage.MATERIAL_SHARE);
shareReportButton.getStyle().setBgColor(ParametresGeneraux.accentColor);
shareReportButton.getPressedStyle().setBgColor(ParametresGeneraux.darkPrimaryColor);
shareReportButton.setTextToShare("I reported this via the great app ABCD "!"
);
shareReportButton.setImageToShare(currentReport.getPhotoPath(), ImageIO.FORMAT_PNG);
我在模拟器下按预期工作,但在实际的 Android 4.4 设备上,我得到一个对话框菜单,其中显示“没有应用程序可以执行此操作”。
请注意,可以与本机应用共享照片。
我找不到任何要添加 in the doc 的构建提示。我应该怎么做才能让分享按钮提供一种在社交网络上分享文字+照片的方式?
任何帮助表示赞赏,
问候
编辑
按照@James H 和@Diamond 的回答,图像类型必须设置为mime 类型。因此,将 ImageIO.FORMAT_PNG 替换为“image/jpg”会填充共享菜单。
为了完整起见,请注意文档中的说明
必须使用 FileSystemStorage API 存储图像,并且不应使用 Storage 等其他 API!
因此,即使照片在缓存中,您也必须将其复制到您的主文件夹,然后在 ShareButton 中使用此复制版本。
【问题讨论】:
标签: share codenameone