无法在AndEngine中捕获屏幕截图

时间:2012-08-07 08:43:10

标签: android screenshot andengine

这是我的代码。

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

            }
        });
    }

第一个日志工作正常。但是没有其他日志正常工作。 它没有完成,也没有失败。 任何人都能给我一个解决方案吗?

我要保存的路径是     “/mnt/sdcard/cmtdd.png”

1 个答案:

答案 0 :(得分:1)

以下可能有用..我添加了scene.attach Child(屏幕截图);你的代码。它应该在正确的地方使用。

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

            }
        });
    }