[AC-4816] Native error on Android when I pick image from Downloads using openPhotoGallery
| GitHub Issue | n/a |
| Type | Bug |
| Priority | n/a |
| Status | Closed |
| Resolution | Invalid |
| Resolution Date | 2017-02-23T15:44:56.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Titanium SDK & CLI |
| Labels | n/a |
| Reporter | Hani Hamadeh |
| Assignee | Shak Hossain |
| Created | 2017-02-22T12:08:24.000+0000 |
| Updated | 2017-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
| File | Date | Size |
| app.js | 2017-02-23T13:42:39.000+0000 | 1194 |
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.
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
Hello, According to the error you should remove below line from success. The rest is fine. Thanks.
Ti.API.info(JSON.stringify(event));That was not helpful, can you please reopen it and assign it to someone to look at it ?
Hello, I can test the sample code with commenting the above line and everything is fine.
Test the code.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();Please try outputting the blob's size / height / width or call imageAsResized on an image picked from the downloads folder
After testing with the test code i am unable to reproduce
What SDK / Android version did you try ?
Nexus 6 ... 6.0.1 for the android version
tried this with both the latest build and 6.0.1GA and both work (SDK)