我使用以下功能进行屏幕截图:
public static String saveScreenshotNamePath(String name){
try{
FileHandle fh;
fh = Gdx.files.external(name + ".png");
Pixmap pixmap = getScreenshot(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
PixmapIO.writePNG(fh, pixmap);
pixmap.dispose();
return fh.file().getAbsolutePath();
}catch (Exception e){
return "";
}
}
public void saveScreenshotFromGame(){
path_to_saved_google = saveScreenshotNamePath("google");
}
然后我想用Intent打开那个图像,但是当我打开它时我只看到hourglass picture。为什么会发生这种情况,几秒钟后我就能在图像库中正确地看到图片。
@Override
public void openImage() {
File file = new File(path_to_saved_google);
media_scanner = new SingleMediaScanner(this, file);
try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); }
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path)), "image/png");
startActivity(intent);
}