Jawad Amjad
Jawad Amjad

Reputation: 2552

Unable to Capture Screen shot In AndEngine

HI here is my Code.

public static void TakeScreenShot(String FileName)
{ 
         Log.d("Screen"," Path "+ FileName);

        scr.capture(CAMERA_WIDTH, CAMERA_HEIGHT, FileName, new IScreenCaptureCallback() {
            @Override
            public void onScreenCaptured(final String pFilePath) { 
                Log.d("Screen","Yes "+ pFilePath);

            }

            @Override
            public void onScreenCaptureFailed(final String pFilePath, final Exception pException) { 
                Log.d("Screen","NO "+ pFilePath+"    "+pException);

            }
        });
    }

The first log is working fine. But then no other log is working. Its not completing nor its failing. Can any one give me a solution?

The path where I am saving is "/mnt/sdcard/cmtdd.png"

Upvotes: 0

Views: 901

Answers (1)

Inco Mob
Inco Mob

Reputation: 594

The follwing might work..I have added scene.attachChild(screenCapture); to your code. It should used at the correct place.

public static void TakeScreenShot(String FileName)
{ 
         Log.d("Screen"," Path "+ FileName);

        scene.attachChild(screenCapture); // Attaching screen capture after all rendered.

        scr.capture(CAMERA_WIDTH, CAMERA_HEIGHT, FileName, new IScreenCaptureCallback() {
            @Override
            public void onScreenCaptured(final String pFilePath) { 
                Log.d("Screen","Yes "+ pFilePath);

            }

            @Override
            public void onScreenCaptureFailed(final String pFilePath, final Exception pException) { 
                Log.d("Screen","NO "+ pFilePath+"    "+pException);

            }
        });
    }

Upvotes: 1

Related Questions