0
我创建了一个游戏,它有一个按钮,点击时会拍摄一个屏幕截图。Android上的Libgdx错误当拍摄屏幕截图时
ChangeListener changeListener = new ChangeListener() {
//take screenshot and share
if(actor.equals(shareBtn)){
byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), true);
Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888);
BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
PixmapIO.writePNG(Gdx.files.external("screenShot.png"), pixmap);
pixmap.dispose();
}
};
当我在PC上运行的游戏没有任何问题,但是当我在Android上运行它,我得到这个错误(我的手机拥有外置SD卡)。
com.badlogic.gdx.utils.GdxRuntimeException: Error writing file: screenShot.png (External)
Caused by: java.io.FileNotFoundException: /storage/emulated/0/screenShot.png: open failed: EACCES (Permission denied)
感谢它的工作,但你知道我怎样才能分享屏幕截图?因为我教android会自动检测图像并给出选项分享。 –