0

I use the following code to take an image and assign it to an ImageView. It works perfectly fine on Kindle Fire HD (API 15) but on Google Nexus 7 the device is streaming photo's from Google's Picassa. How can I get the Picassa/streamed photos to work?

@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
protected void onActivityResult(int requestCode, int resultCode, 
           Intent imageReturnedIntent) {
        super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 

        switch(requestCode) { 
        case SELECT_PHOTO:
            if(resultCode == RESULT_OK){  
                Uri selectedImage = imageReturnedIntent.getData();
                String[] filePathColumn = {MediaStore.Images.Media.DATA};

                Cursor cursor = getContentResolver().query(
                                   selectedImage, filePathColumn, null, null, null);
                cursor.moveToFirst();

                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                String filePath = cursor.getString(columnIndex);
                cursor.close();


                Bitmap pic = BitmapFactory.decodeFile(filePath);

                mProfilePic = new BitmapDrawable(getResources(),pic);

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
                    mChangePicImgButton.setBackground(mProfilePic);
                else
                    mChangePicImgButton.setBackgroundDrawable(mProfilePic);
            }
        }
    }
Spentak
  • 3,359
  • 3
  • 21
  • 31

1 Answers1

0

filePath is probably null at

Bitmap pic = BitmapFactory.decodeFile(filePath);

Are you sure the file exists on the device?

EDIT: If you are having problems with Picasa there is an answer here: Retrieve Picasa Image for Upload from Gallery

Community
  • 1
  • 1
nedaRM
  • 1,837
  • 1
  • 14
  • 28
  • I'm simply using the Android photo picker (photoPickerIntent.setType("image/*"); and then I pick an image from the device. Works on Kindle device. – Spentak Sep 06 '13 at 02:34
  • 1
    It looks like the photos that it crashes on are "streamed" from Picassa. Ones that are on the hard disk seem to work. – Spentak Sep 06 '13 at 02:37
  • @Spentak well the show the code where you get the images from Picassa – nedaRM Sep 06 '13 at 03:30
  • I don't grab images from Picassa - Google does it automatically and streams them on the device. This is an unexpected variable - i did not expect some devices to have thumbnails for streamable images. – Spentak Sep 06 '13 at 03:35