如何捕捉场景?

时间:2014-01-19 07:30:27

标签: android andengine

我的代码捕获场景:但是当我必须退出场景时执行onScreenCaptured(单击按钮返回)。如何捕捉场景?

public void TakeScreenShot() {
    String filename = Utilities.getDateTimeNow() + ".png";
    String FileName = Environment
        .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
        + "/" + filename;
    Log.d("Screen", " Path " + FileName);
    ScreenCapture screenCapture = new ScreenCapture();
    scene.attachChild(screenCapture); // Attaching screen capture after all
                                      // rendered.
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int width = MainActivity.this.mRenderSurfaceView.getWidth();
    int height = MainActivity.this.mRenderSurfaceView.getHeight();
    screenCapture.capture(width, height, FileName,
        new IScreenCaptureCallback() {
            @Override
            public void onScreenCaptured(final String pFilePath) {
                Log.d("Screen", "Yes " + pFilePath);

                // UpImageToFB(pFilePath);
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.parse("file://" + pFilePath),
                        "image/*");
                startActivity(intent);
            }

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

            }
        });
}

1 个答案:

答案 0 :(得分:0)

如果要捕获屏幕,则在加载场景后调用captureScreen()方法。 现在,您希望在单击后退按钮时将此捕获的屏幕uri发送到其他活动。如果是这样, 单击后退按钮

调用此Intent