title: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent to activity
body: <p>I m getting this error in my code.
  Please help me.</p>
  
  <p>My code is as follows. I don't know how to solve this. When I click on the add button I want to add all data to the model class and that class should be filled with the list array in main activity.</p>
  
  <pre><code>public class MainActivity extends Activity implements DataTransferInterfase{
  private Button btnSelect,btnShow;
      public int REQUEST_CAMERA=1;
      public int SELECT_IMAGE=0;
      private GridView gridview;
      private CustomAdapter gridAdaptor;
      public TextView tvcounter;
      public ImageItemBin imageItemBin;
      private Uri mCapturedImageUri;
  public static ArrayList&lt;ImageItemBin&gt; publicSelectedImage=new ArrayList&lt;ImageItemBin&gt;();
      public  ArrayList&lt;ImageItemBin&gt; showImagelist=new ArrayList&lt;ImageItemBin&gt;();
  
      public Uri ImageUri;
      private int count=publicSelectedImage.size();
      private int coloumn=3;
      private int row=count/coloumn;
  
      public String imgPath="";
      private Uri fileUri; // file url to store image
      private static final String IMAGE_DIRECTORY_NAME = "Hello Camera";
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          btnSelect=(Button)findViewById(R.id.btnselect);
          btnShow=(Button)findViewById(R.id.btnShow);
          tvcounter=(TextView)findViewById(R.id.tvcounter);
  
  
          publicSelectedImage=new ArrayList&lt;ImageItemBin&gt;();
          //showImagelist=new ArrayList&lt;ImageItemBin&gt;();
          showImagelist=new ArrayList&lt;ImageItemBin&gt;();
          gridview=(GridView) findViewById(R.id.gridLayout_main);
  //        gridAdaptor=new CustomAdapter(MainActivity.this,publicSelectedImage);
  //        gridview.setAdapter(gridAdaptor);
          //gridAdaptor(R.layout.custom_grid_item_layout,getView());
          //gridLayout.addView(gridAdaptor.getView());
          //gridLayout.addView(inflater.inflate(R.layout.custom_grid_item_layout,null));
          //gridLayout.addView(img);
  
          //tvcounter.setText(CountRecord(imageItemBin));
          //tvcounter.setText(CustomAdapter.result+"");
          showImagelist.add(CustomAdapter.showBin);
          tvcounter.setText(showImagelist.size());
          //showImagelist.add(CustomAdapter.result);
          //tvcounter.setText(counter);
  
          btnSelect.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  //custom dialogBox
                  final Dialog dialog=new Dialog(MainActivity.this);
                  dialog.setContentView(R.layout.custom_dialog_layout);
                  dialog.setTitle("Select from..");
  
                  //set the custom dialog components
                  TextView txtmsg=(TextView)dialog.findViewById(R.id.txtmsg);
                  Button btnGallaery=(Button)dialog.findViewById(R.id.btngallery);
                  Button btnCamara=(Button)dialog.findViewById(R.id.btncamara);
  
                  btnGallaery.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          Intent image=new Intent();
                          image.setType("image/*");
                          image.setAction(Intent.ACTION_GET_CONTENT);
                          startActivityForResult(Intent.createChooser(image,"select file"),SELECT_IMAGE);
                          dialog.dismiss();
                      }
                  });
  
  
  
  
                  btnCamara.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          Intent cam=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                          /*if(cam.resolveActivity(getPackageManager())!=null){
                              String filename="temp.jpg";
                              ContentValues values=new ContentValues();
                              values.put(MediaStore.Images.Media.TITLE,filename);
                              mCapturedImageUri=getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,values);*/
  
                           //cam.putExtra(MediaStore.EXTRA_OUTPUT,setImageUri());
  
                          fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
  
                          cam.putExtra("Image", fileUri);
                          startActivityForResult(cam,REQUEST_CAMERA);
                          dialog.dismiss();
                         // }
  
  
                      }
                  });
  
                  dialog.show();
              }
          });
  
  
          btnShow.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
              }
          });
      }
  
  
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if(requestCode==SELECT_IMAGE){
              if(resultCode==RESULT_OK &amp;&amp; null!=data){
                for (int i=0,c=0,r=0;i&lt;count;i++,c++){
                    if(c==coloumn){
                          c=0;
                          r++;
                     }
  
                }
  
                  ImageUri=data.getData();
                  imageItemBin=new ImageItemBin();
                  imageItemBin.setImage(ImageUri.toString());
                  publicSelectedImage.add(imageItemBin);
  
                  gridAdaptor=new CustomAdapter(MainActivity.this,publicSelectedImage,this);
                  gridview.setAdapter(gridAdaptor);
  
              }
          }
          if(requestCode==REQUEST_CAMERA)
          {
              if(resultCode==RESULT_OK &amp;&amp; data!=null){
                  /*String[] projection={MediaStore.Images.Media.DATA};
                  Cursor cursor=managedQuery(mCapturedImageUri,projection,null,null,null);
                  int coloumn_index_data=cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                  cursor.moveToFirst();
                  String picturePath=cursor.getString(coloumn_index_data);
                  Uri selectedImage=data.getData();
                  imageItemBin=new ImageItemBin();
                  imageItemBin.setImage(selectedImage.toString());
                  publicSelectedImage.add(imageItemBin);*/
  
  //                gridAdaptor=new CustomAdapter(MainActivity.this,publicSelectedImage);
  //                gridview.setAdapter(gridAdaptor);
  
  
                  Bitmap mphoto = (Bitmap) data.getExtras().get("data");
  
                  String stringImage=BitMapToString(mphoto);
  
                 // String getimage=getImagePath();
  
  
                  imageItemBin=new ImageItemBin();
                  imageItemBin.setImage(stringImage);
                  //imageItemBin.setImage(picturePth.toString());
                  publicSelectedImage.add(imageItemBin);
                  gridAdaptor=new CustomAdapter(MainActivity.this,publicSelectedImage,this);
                  gridview.setAdapter(gridAdaptor);
                  //gridAdaptor.notifyDataSetChanged();
  
                 // tvcounter.setText(counter);
                  //publicSelectedImage=selectedImage;
              }
          }
  
  
      }
  
  
      public Uri setImageUri() {
          // Store image in dcim
          File file = new File(Environment.getExternalStorageDirectory() + "/DCIM/", "image" + new Date().getTime() + ".png");
          Uri imgUri = Uri.fromFile(file);
          this.imgPath = file.getAbsolutePath();
          return imgUri;
      }
  
  
      public String getImagePath() {
          return imgPath;
      }
      /*private List&lt;ImageItemBin&gt; DisplayImage(){
          ImageItemBin itembin=new ImageItemBin();
          itembin.getImage();
      }*/
  
  
  
      public Uri getOutputMediaFileUri(int type) {
          return Uri.fromFile(getOutputMediaFile(type));
      }
  
      /*
       * returning image / video
       */
      private static File getOutputMediaFile(int type) {
  
          // External sdcard location
          /*File mediaStorageDir = new File(
                  Environment
                          .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                  IMAGE_DIRECTORY_NAME);
  */
          //File file = new File(Environment.getExternalStorageDirectory() + "/DCIM/", "image" + new Date().getTime() + ".jpg");
  
          // Create the storage directory if it does not exist
         /*if (!file.exists()) {
              if (!file.mkdirs()) {
                  Log.d(IMAGE_DIRECTORY_NAME, "Oops! Failed create "
                          + IMAGE_DIRECTORY_NAME + " directory");
                  return null;
              }
          }*/
  
          // Create a media file name
          //String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",
                 // Locale.getDefault()).format(new Date());
          File mediaFile;
          if (type == MEDIA_TYPE_IMAGE) {
  
               mediaFile = new File(Environment.getExternalStorageDirectory() + "/DCIM/", "image" + new Date().getTime() + ".jpg");
  
  
          } /*else if (type == MEDIA_TYPE_VIDEO) {
              //mediaFile = new File(file.getPath() + File.separator
                     // + "VID_" + timeStamp + ".mp4");
          }*/ else {
              return null;
          }
  
          return mediaFile;
          //return file;
      }
  
  
      private Bitmap previewCapturedImage(Uri file)
      {
          Bitmap bitmap=null;
          try {
              // hide video preview
              //videoPreview.setVisibility(View.GONE);
  
              //imgPreview.setVisibility(View.VISIBLE);
  
              // bimatp factory
              BitmapFactory.Options options = new BitmapFactory.Options();
  
              // downsizing image as it throws OutOfMemory Exception for larger
              // images
              options.inSampleSize = 8;
  
              bitmap = BitmapFactory.decodeFile(file.getPath(),
                      options);
  
              return bitmap;
              //imgPreview.setImageBitmap(bitmap);
          } catch (NullPointerException e) {
              e.printStackTrace();
          }
          return bitmap;
      }
  
  
      public String BitMapToString(Bitmap bitmap){
          ByteArrayOutputStream baos=new  ByteArrayOutputStream();
          bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
          byte [] b=baos.toByteArray();
          String temp= Base64.encodeToString(b, Base64.DEFAULT);
          return temp;
      }
  
  
      public Bitmap StringToBitMap(String encodedString){
          try{
              byte [] encodeByte=Base64.decode(encodedString,Base64.DEFAULT);
              Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
              return bitmap;
          }catch(Exception e){
              e.getMessage();
              return null;
          }
      }
  
  
      public static int totalAmt=0;
  
      @Override
      public int CountRecord(ImageItemBin bin) {
          //for (int i=0;i&lt;count;i++){
              totalAmt=totalAmt+1;
         // }
          return totalAmt;
      }
  }
  </code></pre>