0

I developing an app that takes photo through camera and crops it and displays it in imageview also saves the data to the database. I am receiving following error in onActivityResult

Here's Logcat ERROR!

*ERROR***

Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.android.project.birthdayreminder/com.android.project.birthdayreminder.ContactInfoMoreOption}: java.lang.NullPointerException

CameraActivity.java

Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(captureIntent, CAMERA_REQUEST);


protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode==CAMERA_REQUEST) {
            if (resultCode==RESULT_OK) {                
                picUri = data.getData();
                Log.v("picUri", picUri.toString());             
                performCrop();
            }
        }

        else if (requestCode==PICK_CROP) {
            if (resultCode==RESULT_OK) {
                View view=getLayoutInflater().inflate(R.layout.list_row,null);
                ImageView imgView=(ImageView)view.findViewById(R.id.list_image);
                Bundle extras = data.getExtras();
                Bitmap bitmap = extras.getParcelable("data");
                byte bitObj[]=BirthdayCalculation.convertImageToByte(bitmap);
                Log.v("Photo byte.......", bitObj.toString());              
                ContentValues values=new ContentValues();
                values.put(BirthdayProvider.PHOTO, bitObj);
                int count=getContentResolver().update(BirthdayProvider.CONTENT_URI, values, BirthdayProvider.NUMBER+"='"+SearchListActivity.longClickValue+"'", null);
                if (count==1) {
                    finish();
                    imgView.setImageBitmap(bitmap);
                    //bitmap=BitmapFactory.decodeByteArray(bitObj, 0, bitObj.length);
                    //imgView.setScaleType(ScaleType.FIT_XY);                   
                    Toast.makeText(getBaseContext(),"Updated Successfully",Toast.LENGTH_SHORT).show();
                }
                else{
                     Toast.makeText(getBaseContext(),"Updation Failed",Toast.LENGTH_SHORT).show();
                 }
            }           
        }
    }
}

public void performCrop(){
        Intent cropIntent = new Intent("com.android.camera.action.CROP");      
    cropIntent.setDataAndType(picUri, "image/*");
    cropIntent.putExtra("crop", "true");
    cropIntent.putExtra("aspectX", 1);
    cropIntent.putExtra("aspectY", 1);
    cropIntent.putExtra("outputX", 256);
    cropIntent.putExtra("outputY", 256);
    cropIntent.putExtra("return-data", true);
    startActivityForResult(cropIntent, PICK_CROP);
    }
karthik
  • 165
  • 14

1 Answers1

0

I'm assuming that you are trying to extract Bitmap from the Intent data...If my assume is true then you can try as follows...

Bundle pictureExtra = intent.getExtras();
Bitmap bitmap = (Bitmap) pictureExtra.get("data");

Update:

You can look at these link:

Android - Problem getting image uri

Android ACTION_IMAGE_CAPTURE Intent

Community
  • 1
  • 1
Hamid Shatu
  • 9,664
  • 4
  • 30
  • 41