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

时间:2016-09-23 06:27:05

标签: java android ios libgdx

我正在使用 libgdx 为Android和 ios 开发游戏。 我已经使用此功能获取了截图

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 中分享获取的屏幕截图?

1 个答案:

答案 0 :(得分:1)

获取ScreenShot的路径并将其发送如下

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不会同时收到图片和文字。