Question

i made an application that will allow the user to take a camera shot and edit it using my application. I own a samsung galaxy stellar and it works fine on it. I had my friend download the application and when she tested it on her phone, my application crashes whenever she takes a picture and hit "save". shes using a galaxy s3.

Heres my code when im taking a picture

case R.id.ibTakePic:

i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+File.sep    arator + fileName2 + ".jpg");
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
rotatePic = true;
startActivityForResult(i,cameraData);
break;

and heres my result code..

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);

     if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
            Uri selectedImage = data.getData();
            String[] filePathColumn = { MediaStore.Images.Media.DATA };
            pictake = true;
            Cursor cursor = getContentResolver().query(selectedImage,
                    filePathColumn, null, null, null);
            cursor.moveToFirst();

            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String picturePath = cursor.getString(columnIndex);
            cursor.close();
            rotatePic = false;
            bmpReceive = rotate(picturePath);

            bmpOriginal = bmpReceive; 

            picTaken.setImageBitmap(bmpReceive);
   //         ImageView imageView = (ImageView) findViewById(R.id.imgView);
     //       imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));


        }
Was it helpful?

Solution

I had a similar problem so I switched to this:

Uri uri= data.getData();
InputStream in = context.getContentResolver().openInputStream(uri);
Bitmap b = BitmapFactory.decodeStream(in);

hope it helps

OTHER TIPS

Well, Logs help. But here is my guess.

If you check the Documentation. http://developer.android.com/reference/android/content/ContentResolver.html

A query can return a Cursor object or null. In your code you are not checking for the null. I suggest you try with that. In any case you should always put null checks wherever there is a chance for a null to be returned.

If you can provide the logs then we can tell you the exact problem.

Maybe the bitmap is too big and you get an out of memory. Check that page to know how to deal with that situation:

http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top