Java 如何在whatsapp和facebook上分享libgdx游戏分数的截图?

Java 如何在whatsapp和facebook上分享libgdx游戏分数的截图?,java,android,ios,libgdx,Java,Android,Ios,Libgdx,我正在为android和ios开发一款使用libgdx的游戏。 我已经用这个功能获得了截图 public void take() { byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); Pixmap pixmap = new Pixmap(Gdx.graphics.getWidth(), Gdx.graph

我正在为android和ios开发一款使用libgdx的游戏。 我已经用这个功能获得了截图

public void take() {
    byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);

    Pixmap pixmap = new Pixmap(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), Pixmap.Format.RGBA8888);
    BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
    PixmapIO.writePNG(Gdx.files.external("mypixmap.png"), pixmap);
    pixmap.dispose();
}

我如何在facebook和whatsapp中共享获得的屏幕截图?

获取屏幕截图的路径并按如下方式发送

Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("image/*");
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(Intent.createChooser(share, "Share image File"));

注意:Whatsapp不会同时接收图像和文本。

谢谢。我认为这段代码是针对android的。我需要一个libgdx(独立于平台)的代码,它可以在android和ios上运行。这是不可能的。Android和iOS处理意图的方式不同。您必须实现类似于。