如何使用 getData 设置在 imageview 上捕获的图像?当我运行它时,单击“确定”,应用程序将关闭。
if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
first_image.setImageBitmap(photo);
String[] projection = {};
Cursor cursor = getContentResolver().query(fileUri, projection, null, null, null);
int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String capturedImageFilePath = cursor.getString(column_index_data);
最佳答案
你可以试试这个
在获取路径后附加此代码
File imgFile = new File(capturedImageFilePath );
if(imgFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);
myImage.setImageBitmap(myBitmap);
}
关于java - 如何在imageview上设置捕获的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29791218/