getOutputMediaFile(int)未定义类型new Camera.PictureCallback(){}错误令我困惑

Cod*_*ver 6 java eclipse android

我无法弄清楚为什么会这样.这可能是一个我无法辨认的愚蠢错误.错误再次出现:

getOutputMediaFile(int) is undefined for the type new Camera.PictureCallback(){}

我的代码:

public static final int MEDIA_TYPE_IMAGE = 1;
    private PictureCallback mPicture = new PictureCallback() {

        public void onPictureTaken(byte[] data, Camera camera) {

            File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
            try {
                FileOutputStream fos = new FileOutputStream(pictureFile);
                fos.write(data);
                fos.close();
            } catch (FileNotFoundException e) {
                //Log.d(TAG, "File not found: " + e.getMessage());
            } catch (IOException e) {
               // Log.d(TAG, "Error accessing file: " + e.getMessage());
            }
        }
    };
Run Code Online (Sandbox Code Playgroud)

war*_*ero 33

如果你到达这里是因为相机示例向下向下滚动到文档中,方法是在最后编写的,因为它对于视频和图像捕获都是常见的 http://developer.android.com/guide/topics/media/camera. HTML#储蓄-媒体