1

I make a screen capture using the function below:

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");
}

I then want to open that image with an Intent but I when I open it I only see an hourglass picture . Why does this happen, I can see the picture correctly in the Image Gallery a few seconds later.

@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);
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.