繁体   English   中英

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

[英]How to share screenshot of libgdx game score in whatsapp and facebook?

我正在使用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();
}

我如何在facebookwhatsapp 中分享获得的屏幕截图?

获取 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 不会同时接收图像和文本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM