2

将 uri 传递给相机意图时,我试图将完整的相机图像保存到指定的 Uri。但它不会返回 onActvityResult。但是,我尝试在 onActivityResult 中使用 Bundle 获取图像,但它返回一个缩略图。我已经尝试了很多教程,他们都遇到了这个问题。你能帮忙吗!!!

            Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File u = getTempFile();
            picUri = Uri.fromFile(u);
            camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(u));

            startActivityForResult(camera, TAKE_PICTURE);

onActivityResult

            if (requestCode == TAKE_PICTURE && resultCode == RESULT_OK  && null != data) 
            {
            Toast.makeText(this, "Image saved to:\n"+picUri, Toast.LENGTH_LONG).show();
            }
4

1 回答 1

0

尝试下面给出的代码:

                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                File f = new File(android.os.Environment
                        .getExternalStorageDirectory(), "temp.jpg");

                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
                startActivityForResult(intent, REQUEST_CAMERA); 


                protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                   super.onActivityResult(requestCode, resultCode, data);
                    if (resultCode == RESULT_OK) {
                      if (requestCode == REQUEST_CAMERA) {

                      File f = new File(Environment.getExternalStorageDirectory()
                      .toString());

                 for (File temp : f.listFiles()) {
                if (temp.getName().equals("temp.jpg")) {
                    f = temp;
                    break;
                      }
                    }

                String path = f.getAbsolutePath();
     } }

   }
于 2013-11-18T09:08:50.890 回答