Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

FileNotFoundException no BitmapFactory.decodeFile()

Seguindo junto ao vídeo, no momento em que vai ser feito o redimensionamento da foto para carregar no formulário a exception é lançada, ainda que a foto tenha sido salva no mesmo endereço que é informado ao decodeFile().

foto.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                Intent irParaCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

                Uri imageLocation = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
                irParaCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageLocation); // set the image file name

                imagePath = imageLocation.toString();

                irParaCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageLocation); // set the image file name

                startActivityForResult(irParaCamera, 100);
            }
        });
public void loadFoto(String imagePath) {
        contato.setFoto(imagePath);
        Bitmap imagem = BitmapFactory.decodeFile(imagePath);
        Bitmap thumb = Bitmap.createScaledBitmap(imagem, 100, 100, true);
        foto.setImageBitmap(thumb);
    }
Unable to decode stream: java.io.FileNotFoundException: /file:/storage/emulated/0/Pictures/AgendaPictures/IMG_20140602_162448.jpg: open failed: ENOENT (No such file or directory)

Mesmo seguindo a documentação da API do Android como em http://developer.android.com/guide/topics/media/camera.html continua não funcionando.

Estou utilizando o meu aparelho (Nexus 4 - 4.4.2) ao invés do AVD.

1 resposta
solução!

Consegui resolver, foi necessário apenas passar o valor relativo ao imagePath.

imagePath = imageLocation.toString().replace("file:///", "");

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software