Uploaded image for project: 'Appcelerator - INBOX'
  1. Appcelerator - INBOX
  2. AC-1474

openPhotoGallery + Remote Image = NullPointerException

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Component/s: Titanium SDK & CLI
    • Environment:

      TitaniumSDK 3.4.1GA
      AndroidSDK 16
      Hardware Device Nexus 5 with Native Storage Encryption, running Android L

      Description

      Problem

      I've come across a nasty bug when using openPhotoGallery() where accessing the returned media.nativePath causes a NullPointException. Now, this only happens when the selected media, for some reason, appears to become a remote media (i.e. after automatic backup of Photo Gallery).
      Even weirder, if I use an ImageView to display the image, it is displayed correctly. Initially I hit the bug when trying to upload the selected image. I was then able to reproduce the bug with this minimal code:

      Test case

      1. Create a new Default Alloy Project
      2. Replace the initial doClick() function, within index.js:

      index.js

      function doClick(e){
      	Titanium.Media.openPhotoGallery({
          	success:function(event) {
          		try {
          			Ti.API.info('event.media.nativePath: ' + event.media.nativePath); 
          		}
          		catch(e) {
          			Ti.API.error(e.message);
          		}	
                  Ti.API.info('event.media.file.nativePath: ' + event.media.file.nativePath);   
              }
      	});
      };
       
      $.index.open();
      
      

      3. Select a picture (using Google Photos, now the default on Android L) that has been backed up to the Cloud

      Logs

      Output for a picture before it has been backed up / local picture:

      [INFO] :   event.media.nativePath: file:///storage/emulated/0/DCIM/Camera/IMG_20141210_232913.jpg
      [INFO] :   event.media.file.nativePath: content://media/external/images/media/20559
      

      Output for a picture after it has been backed up / remote picture:

      [ERROR] :  Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
      [INFO] :   event.media.file.nativePath: content://com.google.android.apps.photos.content/0/https%3A%2F%2Flh6.googleusercontent.com%2FxAiJOX8hSsSutQeA6X96og8RzpRo2PyOtWi_49FaNSMv%3Ds0-d
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rtlechuga Radamantis Torres-Lechuga (Inactive)
                Reporter:
                felipekk Felipe Knaesel Koch
              • Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code