[英]How to share screenshot of libgdx game score in whatsapp and facebook?
I am developing a game using libgdx for android and ios .我正在使用libgdx为 android 和ios开发游戏。 I have already obtained screenshot using this function,我已经使用此功能获得了屏幕截图,
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();
}
How can i share obtained screenshot in facebook and whatsapp ?我如何在facebook和whatsapp 中分享获得的屏幕截图?
Get the path of your ScreenShot and send it like below获取 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"));
Note : Whatsapp dont receive image and text both together.注意:Whatsapp 不会同时接收图像和文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.