Titanium JIRA Archive
Appcelerator Community (AC)

[AC-4816] Native error on Android when I pick image from Downloads using openPhotoGallery

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2017-02-23T15:44:56.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterHani Hamadeh
AssigneeShak Hossain
Created2017-02-22T12:08:24.000+0000
Updated2017-02-27T19:12:01.000+0000

Description

On android when I try to pick an image from downloads folder using openPhotoGallery I get an error when I try to access the blob object's functions and properties like blob.length or blob.imageAsResized

Attachments

FileDateSize
app.js2017-02-23T13:42:39.000+00001194

Comments

  1. Sharif AbuDarda 2017-02-22

    Hello, Please share a sample code that demonstrate the issue. Please create a sample app.js code that we can test to validate the bug. Thanks.
  2. Hani Hamadeh 2017-02-23

    When I run this project and pick an image from the downloads folder I get the following error: ERROR] : TiExceptionHandler: (main) [3213,3213] ----- Titanium Javascript Runtime Error ----- [ERROR] : TiExceptionHandler: (main) [0,3213] - In undefined:33,23 [ERROR] : TiExceptionHandler: (main) [0,3213] - Message: Uncaught Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference [ERROR] : TiExceptionHandler: (main) [0,3213] - Source: Ti.API.info(JSON.stringify(event)); code attached
  3. Sharif AbuDarda 2017-02-23

    Hello, According to the error you should remove below line from success. The rest is fine. Thanks.
                           Ti.API.info(JSON.stringify(event));
       
  4. Hani Hamadeh 2017-02-23

    That was not helpful, can you please reopen it and assign it to someone to look at it ?
  5. Sharif AbuDarda 2017-02-23

    Hello, I can test the sample code with commenting the above line and everything is fine.
       var win = Ti.UI.createWindow({
           backgroundColor : 'white'
       });
       
       var btn = Ti.UI.createButton({
           title : 'Pick',
           top : 50,
           height : Ti.UI.SIZE,
           width : Ti.UI.SIZE
       });
       
       var imageView = Ti.UI.createImageView({
           height : 500,
           width : 500,
           top : 300
       });
       win.add(imageView);
       
       var ensureStoragePermissions = function(cb) {
           if (Ti.Filesystem.hasStoragePermissions() && cb)
               cb();
           else {
               Ti.Filesystem.requestStoragePermissions(function(e) {
                   if (e.success && cb)
                       cb();
               });
           }
       
       };
       
       btn.addEventListener('click', function() {
           ensureStoragePermissions(function() {
               Titanium.Media.openPhotoGallery({
                   success : function(event) {
                       // called when media returned from the camera
                       Ti.API.debug('Our type was: ' + event.mediaType);
                       if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
                           //Ti.API.info(JSON.stringify(event));
                           imageView.image = event.media;
                       } else {
                           alert("got the wrong type back =" + event.mediaType);
                       }
                   },
                   cancel : function() {
                       // called when user cancels taking a picture
                   },
                   error : function(error) {
                       // called when there's an error
       
                   },
                   saveToPhotoGallery : true,
                   // allowEditing and mediaTypes are iOS-only settings
                   allowEditing : true,
                   mediaTypes : [Ti.Media.MEDIA_TYPE_VIDEO, Ti.Media.MEDIA_TYPE_PHOTO]
               });
       
           });
       });
       win.add(btn);
       win.open();
       
    Test the code.
  6. Hani Hamadeh 2017-02-23

    Please try outputting the blob's size / height / width or call imageAsResized on an image picked from the downloads folder
  7. Andy Waldman 2017-02-24

    After testing with the test code i am unable to reproduce
  8. Hani Hamadeh 2017-02-24

    What SDK / Android version did you try ?
  9. Andy Waldman 2017-02-24

    Nexus 6 ... 6.0.1 for the android version
  10. Andy Waldman 2017-02-27

    tried this with both the latest build and 6.0.1GA and both work (SDK)

JSON Source