problems taking photo "onActivityResult"
<p>I have a problem with the camera and in many cases to take the picture and take it to the ImageView, get error.</p>

<pre><code>java.lang.RuntimeException: Unable to resume activity {co.com.xxxx.xxxx/xxxx.xxxx.screens.formularioScreen}:
 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent
 { act=inline-data (has extras) }} to activity {xxxx.xxxx,screens/xxxx.xxxx.screens.formularioScreen}:
 java.lang.NullPointerException
</code></pre>

<p>My code to take photo is the following:</p>

<pre><code>    Button oButton = new Button(this);
    oButton.setText("take Photo");
    oButton.setOnClickListener(new OnClickListener() {              
        public void onClick(View v) {

            oImageActual = oView; //variable final = ImageView
            Intent intent =  new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(intent, TAKE_PICTURE);
        }                       
    });

//layout = container
layout.addView(oButton);
</code></pre>

<p>and I have the method onActivityResult</p>

<pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == TAKE_PICTURE) {          
        if (data != null) {             
            if (data.hasExtra("data")) {
                oImageActual.setImageBitmap((Bitmap) data.getParcelableExtra("data"));
            }               
        }
    }
}
</code></pre>

<p>Not if I'm missing some try / catch or something, but the error happens frequently.</p>

<p>Any ideas?</p>

<hr>

<p>The error still appears, there are times when it does not, and others so.<br>
Try placing it oneilse14 said,</p>

<pre><code>oImageActual.setImageBitmap((Bitmap) data.getExtras().get("data"));
</code></pre>

<p>but the error remained the same. Anyone know why this happens or how to prevent it?</p>

<hr>

<p>Start the camera with a button</p>

<pre><code>oButton.setText("Take photo");
oButton.setOnClickListener(new OnClickListener() {              
    public void onClick(View v) {       
        oImageActual = oView; //oImageActual ImageView is a final variable = new ImageVew(this);
        Intent intent =  new Intent(MediaStore.ACTION_IMAGE_CAPTURE);                           
        startActivityForResult(intent, TAKE_PICTURE);
    }                       
});
LinAyout.addView(oButton);
</code></pre>

<p>And this is the onActivityResult.</p>

<pre><code>/**
 * Al terminar la actividad de la camara, se ejecuta este metodo para continuar
 */
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);      
    if (requestCode == TAKE_PICTURE &amp;&amp; (resultCode == Activity.RESULT_OK)) {            
        if (data != null) {         
            if (data.hasExtra("data")) {                
                oImageActual.setImageBitmap((Bitmap) data.getParcelableExtra("data"));
            }   
        }
    }
}
</code></pre>
