title: Android capture image and display
body: <p>I have develop android application to capture the image and display. When I run the code code it opens the camera and and when it goes to display it gives me <code>java.lang.NullPointerException</code> </p>
  
  <p>This is my code.</p>
  
  <pre><code>package com.www.dermatroid;
  
  import java.io.FileNotFoundException;
  import java.io.InputStream;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.neuroph.contrib.imgrec.ImageRecognitionPlugin;
  import org.neuroph.contrib.imgrec.image.Image;
  import org.neuroph.contrib.imgrec.image.ImageFactory;
  import org.neuroph.core.NeuralNetwork;
  
  import android.app.Activity;
  import android.app.Dialog;
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.database.Cursor;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.drawable.BitmapDrawable;
  import android.net.Uri;
  import android.os.Bundle;
  import android.provider.MediaStore;
  import android.util.Log;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.View.OnTouchListener;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class Main extends Activity implements OnTouchListener {
  
  private final int SELECT_PHOTO = 1;
  private final int LOADING_DATA_DIALOG = 2;
  private final int RECOGNIZING_IMAGE_DIALOG = 3;
  private static final int CAMERA_REQUEST = 1888; 
  
  private TextView txtAnswer;
  private LinearLayout screen;
  
  private Bitmap bitmap;
  private Image image;
  
  private NeuralNetwork nnet;
  private ImageRecognitionPlugin imageRecognition;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      txtAnswer = (TextView) findViewById(R.id.txtAnswer);
      screen = (LinearLayout) findViewById(R.id.screen);
      screen.setOnTouchListener(this);
      loadData();
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
  
  
              switch (requestCode) {
             case CAMERA_REQUEST:
                  if (resultCode == RESULT_OK) {                     
                            Bitmap photo = (Bitmap) data.getExtras().get("data");
                            txtAnswer.setCompoundDrawablesWithIntrinsicBounds(null, null, null, new BitmapDrawable(photo));                               
                  }
                  break;
                default:
                  break;
              }          
  }
  @Override
  public boolean onTouch(View v, MotionEvent event) {
  
      Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
      startActivityForResult(cameraIntent, CAMERA_REQUEST);       
      return false;
  }
  
  }
  </code></pre>
  
  <p>the log result</p>
  
  <pre><code>06-13 11:46:38.978: E/AndroidRuntime(3346): FATAL EXCEPTION: main
  06-13 11:46:38.978: E/AndroidRuntime(3346): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.www.dermatroid/com.www.dermatroid.Main}: java.lang.NullPointerException
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at android.app.ActivityThread.access$2000(ActivityThread.java:117)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at  android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at android.os.Handler.dispatchMessage(Handler.java:99)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at android.os.Looper.loop(Looper.java:130)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at android.app.ActivityThread.main(ActivityThread.java:3687)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at java.lang.reflect.Method.invokeNative(Native Method)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at java.lang.reflect.Method.invoke(Method.java:507)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at dalvik.system.NativeStart.main(Native Method)
  06-13 11:46:38.978: E/AndroidRuntime(3346): Caused by: java.lang.NullPointerException
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at org.neuroph.contrib.imgrec.ImageRecognitionPlugin.setInput(ImageRecognitionPlugin.java:106)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at org.neuroph.contrib.imgrec.ImageRecognitionPlugin.recognizeImage(ImageRecognitionPlugin.java:176)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at com.www.dermatroid.Main.recognize(Main.java:140)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at com.www.dermatroid.Main.onActivityResult(Main.java:71)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at android.app.Activity.dispatchActivityResult(Activity.java:3908)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
  06-13 11:46:38.978: E/AndroidRuntime(3346):     ... 11 more
  </code></pre>
  
  <p>it gives error at <code>Bitmap photo = (Bitmap) data.getExtras().get("data");</code></p>