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)
ありがとうございますが、どのようにスクリーンショットを共有できますか?アンドロイドには自動的に画像が検出され、共有するオプションが与えられているからです。 –