当我拍照时,它无法验证,但取消按钮运行?

时间:2015-02-07 11:45:34

标签: android camera fragment onactivityresult

我的片段有问题。 我正在尝试拍照,当我启动相机拍摄图像时,凸轮运行 但在捕获图像后,验证按钮无法正常工作

startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);

所以必须关闭相机。

我在onActivityResult中测试它

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        // if the result is capturing Image

         super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {

            if (resultCode == Activity.RESULT_OK) {

                 Toast.makeText(getActivity(),
                         "User validate image capture", Toast.LENGTH_SHORT)
                         .show();
}}

但是我测试了它的取消按钮:

  if (resultCode == Activity.RESULT_CANCELED) {

                // user cancelled Image capture
                Toast.makeText(getActivity(),
                        "User cancelled image capture", Toast.LENGTH_SHORT)
                        .show();

}

0 个答案:

没有答案