1

I'm using this method to take pictures in my app, however in onActivityResult I try to load the picture like this:

if (requestCode == TAKE_PICTURE) {
        if (resultCode == RESULT_OK) {
            Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath);
            // Do something with it

However the bitmap is null, if I set a breakpoint at that spot the image can be loaded normaly, however if I implement the procedure in a new app it's always ready to be loaded. What am I doing wrong?

user_4685247
  • 2,878
  • 2
  • 17
  • 43
  • Did you tried doing it like in the tutorial ?: Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("data"); – yan yankelevich Jun 29 '16 at 11:55
  • please do some debugging ... like `Log.d(TAG, "path: \"" + mCurrentPhotoPath + "\"");` ... i bet that you would get `TAG: path:"null"` – Selvin Jun 29 '16 at 11:56
  • From what I've read, the bitmap from extras is merely a 300x300 thumbnail – user_4685247 Jun 29 '16 at 11:57
  • *merely a 300x300 thumbnail* ... or even on some devices is null – Selvin Jun 29 '16 at 11:57
  • the path that you've asked me to log points to an image that exists, and is indeed a valid picture. However, when the onActivityResult is called, the image seems to be incomplete, while in the demo app in which I first implemented this had the image written and available at that point – user_4685247 Jun 29 '16 at 12:07
  • [could you post `launchMode` of YOUR activity from the manifest which calls `dispatchTakePictureIntent`](http://stackoverflow.com/questions/16592623/onactivityresult-getting-called-as-soon-as-camera-intent-is-sent) – Selvin Jun 29 '16 at 12:12
  • I did not set a launchMode – user_4685247 Jun 29 '16 at 12:14
  • perhaps worth noting, the onActivityResult is not called after sending the intent, but after actually taking the picture. – user_4685247 Jun 29 '16 at 12:28
  • Are you getting null pointer exception or any other? – Smit.Satodia Jun 29 '16 at 13:03
  • the value of bitmap is null, no exception is thrown whatsoever. – user_4685247 Jun 29 '16 at 13:05

0 Answers0