Java 谷歌眼镜拍照意向

Java 谷歌眼镜拍照意向,java,android,android-intent,android-camera,google-glass,Java,Android,Android Intent,Android Camera,Google Glass,我正在尝试用谷歌眼镜应用程序拍照。因此,我使用了SurfaceView,它在背景中显示相机预览。这张照片是有意拍摄的。 问题是永远不会调用属于intent的onActivityResult方法。我已经读到,这个问题是谷歌眼镜上的一个bug,但应该用谷歌眼镜的更新版本来解决 onCreate方法: private CameraSurfaceView cameraView; @Override public void onCreate(Bundle savedInstanceState) {

我正在尝试用谷歌眼镜应用程序拍照。因此,我使用了SurfaceView,它在背景中显示相机预览。这张照片是有意拍摄的。 问题是永远不会调用属于intent的onActivityResult方法。我已经读到,这个问题是谷歌眼镜上的一个bug,但应该用谷歌眼镜的更新版本来解决

onCreate方法:

private CameraSurfaceView cameraView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initiate CameraView
    cameraView = new CameraSurfaceView(this);

    // Set the view
    this.setContentView(cameraView);

}
意图呼叫:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_camera:
            take picture

            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if (intent != null)
            {

                Toast.makeText(getApplicationContext(), "Taking Picture",
                        Toast.LENGTH_SHORT).show();
                startActivityForResult(intent, TAKE_PICTURE_REQUEST);
            }

            return true;

        default:
            return super.onOptionsItemSelected(item);
    }
}
这一切都很好。用户看到相机预览,当调用意图时,将拍摄并存储一张照片。之后,用户会看到提示“点击接受”。点击后,应用程序结束,但从未调用onActivityResult方法

onActivityResult方法

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    Log.i("Camera", "Hello from onActivityResult");
    // Handle photos
    if (requestCode == TAKE_PICTURE_REQUEST && resultCode == RESULT_OK)
    {


        String picturePath = data.getStringExtra(Intents.EXTRA_PICTURE_FILE_PATH);

        processPictureWhenReady(picturePath);
    }


    super.onActivityResult(requestCode, resultCode, data);

}
释放相机:

@Override
protected void onResume() {
    super.onResume();

    // Do not hold the camera during onResume
    if (cameraView != null) {
        cameraView.releaseCamera();
    }
}

@Override
protected void onPause() {
    super.onPause();

    // Do not hold the camera during onPause
    if (cameraView != null) {
        cameraView.releaseCamera();
    }
}
日志级别为“Info”的我的应用程序的Logcat日志


提前感谢所有的回答和评论

如何确保从未调用onActivityResult?也许您可以在此方法中添加日志并发布logcat跟踪。@SimonMarquis谢谢您的评论。我在我的问题中添加了日志。请参见上面的内容。请确保从IDE日志查看器中删除任何筛选器。顺便问一下,在启动Intent之前,您是否正确地释放了摄影机对象?(例如在onPause中)@SimonMarquis我添加了onPause方法的程序代码,以释放与onActivityResult方法在同一类中的摄影机对象。请看上面。我查看了完整的日志。但是我恐怕要把它全部贴在这里太长了。这里有两行可能很有趣:
05-0311:35:42.065858-1073/?I/CameraClientV1[41b7e250]﹕ 接收到来自照相机的最终jpeg。[时间=9236ms]
05-03 11:35:42.143 858-858/?I/ApiTakePictureActivity[41b17740]﹕ 图片已保存,您现在应该可以看到FileObserver回调。
案例R.id.action\u摄像头:开关案例指的是“点击接受”选项?我假设“来自onActivityResult的Hello”显示在您的日志中。
 05-03 08:45:02.328  29785-29785/com.dhbw.charadect I/dalvikvm-heap﹕ Grow heap (frag case) to 5.955MB for 921616-byte allocation
 05-03 08:45:03.305  29785-29785/com.dhbw.charadect I/Choreographer﹕ Skipped 51 frames!  The application may be doing too much work on its main thread.
 05-03 08:45:03.313  29785-29785/com.dhbw.charadect W/Resources﹕ Converting to boolean: TypedValue{t=0x3/d=0x210 "res/anim/decelerate_interpolator.xml" a=1 r=0x10a0006}
 05-03 08:45:04.008  29785-29785/com.dhbw.charadect I/Choreographer﹕ Skipped 30 frames!  The application may be doing too much work on its main thread.
 05-03 08:45:14.414  29785-29797/com.dhbw.charadect I/Camera﹕ Received CAMERA_MSG_RELEASE