BitmapFactory.decodeFile возвращает ноль, на /storage/emulated/0/DCIM/Camera/IMG_20200407_144901.jpg - PullRequest
0 голосов
/ 09 апреля 2020

Я не знаю, почему BitmapFactory.decodeFile ("/ storage / emulated / 0 / DCIM / Camera / IMG_20200407_144901.jpg") возвращает ноль, если я получаю абсолютный путь из изображения галереи.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Result code is RESULT_OK only if the user selects an Image
    if (resultCode == MainActivity.RESULT_OK)
        switch (requestCode) {
            case GALLERY_REQUEST_CODE:
                //data.getData return the content URI for the selected Image
                Uri selectedImage = data.getData();
                String[] filePathColumn = {MediaStore.Images.Media.DATA};
                // Get the cursor
                Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
                // Move to first row
                cursor.moveToFirst();
                //Get the column index of MediaStore.Images.Media.DATA
                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                //Gets the String value in the column
                String imgDecodableString = cursor.getString(columnIndex);
                cursor.close();
                // Set the Image in ImageView after decoding the String

                //Picasso.with(this).load(imgDecodableString).fit().into(imageView);
                //imageView.setImageURI(data.getData());
                BitmapFactory.Options options = new BitmapFactory.Options ();
                options.inSampleSize = 4;
                imageView.setImageBitmap(BitmapFactory.decodeFile(selectedImage.getPath()));



                break;
           /* case CAMERA_REQUEST_CODE:
                imageView.setImageURI(Uri.parse(cameraFilePath));
                break;*/
            default:
                super.onActivityResult(requestCode, resultCode, data);

        }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...