Android 我正在做一个应用程序,以采取图片,保存和显示,但意图是返回空在上述版本和安卓1.6它的工作罚款
我正在使用这段代码,它在1.6中运行良好,但在4.4中崩溃了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
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()
你好,这个链接可能会帮助您解决同样的问题。过来看。