Taking Picture From Android Camera Issue on multiple Devices

Put your problem here if it does not fit any of the other categories.

Taking Picture From Android Camera Issue on multiple Devices

Postby mr_muskuraha » Mon Dec 31, 2012 9:09 pm

I have been facing strange issue and at least i have tried every alternative way, technique to take picture from camera through intent, saving it to SD card etc..

even exploring whole stackoverflow and Google as well to get solution but i found nothing relevant to my problem.

Problem is: I take picture from camera it works on few phones and many phones just crash, Google says use this code to take picture but it does not work on all devices either :(

Code: Select all
Intent i=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File dir=
                Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);

            output=new File(dir, "CameraContentDemo.jpeg");
            i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output));

            startActivityForResult(i, CONTENT_REQUEST);


@Override
      protected void onActivityResult(int requestCode, int resultCode,
                                      Intent data) {
        if (requestCode == CONTENT_REQUEST) {
          if (resultCode == RESULT_OK) {

              Uri selectedImage = Uri.fromFile(output);
                getContentResolver().notifyChange(selectedImage, null);
                ImageView imageView = (ImageView) findViewById(R.id.imageView1);
                ContentResolver cr = getContentResolver();
                Bitmap bitmap;
                try {
                     bitmap = android.provider.MediaStore.Images.Media
                     .getBitmap(cr, selectedImage);

                    imageView.setImageBitmap(bitmap);
                    Toast.makeText(this, selectedImage.toString(),
                            Toast.LENGTH_LONG).show();
                } catch (Exception e) {
                    Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
                            .show();
                    Log.e("Camera", e.toString());
                }

          }
        }
      }


It Works On these Phones:

    Samsung Galaxy S1,S2
    Sumsung Ace
    Motorola Droid
    Droid Razr Maxx HD

It Does Not Work On these Phones:
    Droid Razr Maxx w
    Xoom tablet

Please put some light on it, whether my code is incorrect or these phones have some issue?

any help would be appreciated.
mr_muskuraha
Senior Developer
Senior Developer
 
Posts: 142
Joined: Wed Jan 13, 2010 8:49 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests