Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我正在做一个应用程序,以采取图片,保存和显示,但意图是返回空在上述版本和安卓1.6它的工作罚款_Android_Android Camera Intent - Fatal编程技术网

Android 我正在做一个应用程序,以采取图片,保存和显示,但意图是返回空在上述版本和安卓1.6它的工作罚款

Android 我正在做一个应用程序,以采取图片,保存和显示,但意图是返回空在上述版本和安卓1.6它的工作罚款,android,android-camera-intent,Android,Android Camera Intent,我正在使用这段代码,它在1.6中运行良好,但在4.4中崩溃了 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = new ExternalStorage(getApplicationContext()).getAlbumStorageDir(); // create a file to save the image intent.putExt

我正在使用这段代码,它在1.6中运行良好,但在4.4中崩溃了

 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                fileUri = new ExternalStorage(getApplicationContext()).getAlbumStorageDir(); // create a file to save the image
                intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
                // start the image capture Intent
                startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);


    /*in onActivityResult*/
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                Uri uri = data.getData();
                try {
                    Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
                    ImageView imageView = (ImageView) findViewById(R.id.image);
                    imageView.setImageBitmap(bitmap);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } else if (resultCode == RESULT_CANCELED) {
            } else {
            }
        }

我看了好几篇文章,但都没有找到正确的。

不需要
动作图像捕获
通过
onActivityResult()返回
Uri


通过
EXTRA\u输出
,您知道图像应该存储在哪里。使用您输入到
EXTRA_OUTPUT
中的值,而不是
data.getData()

你好,这个链接可能会帮助您解决同样的问题。过来看。