Good friends, A few days I've been trying to solve this problem, I see that there are several in the forum, but none have managed to solve my problem.

I have an ImageView and a Button to take the picture. In the event of the button I have this code:

 oButton.setOnClickListener(new OnClickListener() {             
                    public void onClick(View v) {
                        //oImageActual is the final ImageView
                        oImageActual = oView;
                        Intent intent =  new Intent(MediaStore.ACTION_IMAGE_CAPTURE);                           
                        startActivityForResult(intent, TAKE_PICTURE);
                    }                       
                });

and the result of the activity, I have this one:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == TAKE_PICTURE && (resultCode == Activity.RESULT_OK)) {            
        if (data != null) {
            if (data.hasExtra("data")) {                    
                 Bitmap photo = (Bitmap) data.getExtras().get("data"); 
                 oImageActual.setImageBitmap(photo);                    
            }
        }
    }
}

The problem is that several times it works, and fails several times, I mean, funcina, take the photo and puts it in ImageView, but many times you close the application. I have to reboot the phone to work again.

This is the main problem we get:

(...)java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity(...)

If anyone has an answer, please be waiting here, thanks.

1

There are 1 best solutions below

4
On

"take the photo and puts it in ImageView, but many times you close the application."

If i am understanding this right, you are closing the activity before the result is returned. onActivity result only gets the result if the parent activity is not closed during the whole event.