5

I faced problem: ACTION_IMAGE_CAPTURE intent's behaviour depends on hardware manufacturer.

I think, best way to get photo from camera inserted in photo gallery must be something like following

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, CAPTURE_IMAGE_REQUEST);

and then get uri in onActivityResult:

switch (requestCode) {
    case CAPTURE_IMAGE_REQUEST: {
         if(resultCode == Activity.RESULT_OK) {
              Uri uri = intent.getData();// content uri of photo in media gallery
              //do something with this
         }
         break;
    }

But I see, that this doesn't work on many devices; moreover, I found several different scenarios of Camera app behaviour:

  • some devices have bug with this event, so there is no way to get fullsized photos, and you can get 512px wide photo using tmp file in public directory only
  • some devices (including mine) insert taken photo into gallery, but does not return Uri. (getData() returns null, intent extras have only boolean key 'specify-data', value = true) If I try to get photo through the public tempfile then photo will be inserted into both gallery and tempfile.
  • some devices don't insert taken photos to gallery - and I must do it manually
  • I dont know, but there can be other different scenarious

So, is there best practices in managing such problems to cover a wide range of devices and manufacturers?

In this case I need take photo from camera, get it inserted into gallery, then get uri of photo in gallery.

Community
  • 1
  • 1
Arseniy
  • 1,737
  • 1
  • 19
  • 35

1 Answers1

0

A part of this has already been answered :

I don't think you should be checking for other cases. Google and Android OEM's monitor those issues so report them and hopefully they will be fixed.

Community
  • 1
  • 1
Reno
  • 33,594
  • 11
  • 89
  • 102
  • 1
    @muzhig Most of the bugs are fixed, the carriers however don't let the OEM's roll out the upgrades. – Reno Dec 16 '11 at 09:24