{ "id": "101587", "key": "TIMOB-11183", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" }, { "id": "15104", "description": "2013 Sprint 03 API", "name": "2013 Sprint 03 API", "archived": true, "released": true, "releaseDate": "2013-02-11" }, { "id": "14813", "description": "2013 Sprint 03", "name": "2013 Sprint 03", "archived": true, "released": true, "releaseDate": "2013-02-11" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-05-28T16:09:12.000+0000", "created": "2012-09-20T09:51:48.000+0000", "epic": { "id": 105183, "key": "TIMOB-11818", "name": "Android: Camera Bugs", "summary": "Android: Address deficiencies in the Camera implementation", "color": { "key": "color_1" }, "done": false }, "priority": { "name": "High", "id": "2" }, "labels": [], "versions": [ { "id": "14096", "description": "Release 2.1.2", "name": "Release 2.1.2", "archived": true, "released": true, "releaseDate": "2012-08-31" }, { "id": "14137", "description": "Release 2.1.3", "name": "Release 2.1.3", "archived": true, "released": true, "releaseDate": "2012-10-03" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "issuelinks": [], "assignee": { "name": "vivekr", "key": "vivekr", "displayName": "Vivekr", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-05-20T17:56:38.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "When starting an activity for an image crop intent's result, I cannot reach the data returned.\r\nIf i put the extra property ('return-data',true) into it, I can get a the text 'Android.Graphics.Bitmap@' after calling intent.getStringExtra(\"data\"), but the data property of the returned intent is still null.\r\n\r\nI'm attaching a code showing the problem.\r\nIt's almost impossible to let the user crop an image on Android, since the intent is not working and there are too many limitations when dealing with images on Android (such as pinch, scroll, etc).\r\n\r\n{code}\r\nvar curWin = Ti.UI.createWindow({\r\n\tbackgroundColor : '#ffffff',\r\n\t//navBarHidden:true, // IF THIS IS ENABLED THE startActivityForResult NOT WORK\r\n\texitOnClose : true\r\n});\r\n\r\nvar myView = Ti.UI.createView();\r\nvar curBtn = Ti.UI.createButton({\r\n\tcolor : '#000000',\r\n\ttitle : 'Start Crop',\r\n\theight : 'auto',\r\n\twidth : 'auto'\r\n});\r\nmyView.add(curBtn);\r\n\r\ncurBtn.addEventListener('click', function(e) {\r\n\ttry {\r\n\t\tTitanium.Media.openPhotoGallery({\r\n\t\t\tsuccess : function(event) {\r\n\t\t\t\tvar intent = Ti.Android.createIntent({\r\n\t\t\t\t\taction : \"com.android.camera.action.CROP\",\r\n\t\t\t\t\tdata : event.media.nativePath,\r\n\t\t\t\t\ttype : 'image/*'\r\n\t\t\t\t});\r\n\t\t\t\tintent.putExtra(\"outputX\", 200);\r\n\t\t\t\tintent.putExtra(\"outputY\", 200);\r\n\t\t\t\tintent.putExtra(\"aspectX\", 1);\r\n\t\t\t\tintent.putExtra(\"aspectY\", 1);\r\n\t\t\t\tintent.putExtra(\"scale\", true);\r\n\t\t\t\tintent.putExtra(\"return-data\", true);\r\n\t\t\t\tvar activity = Ti.Android.currentActivity;\r\n\t\t\t\tactivity.startActivityForResult(intent, function(param) {\r\n\t\t\t\t\tvar iname = Ti.Android.EXTRA_STREAM;\r\n\t\t\t\t\tif (param.resultCode == Ti.Android.RESULT_OK) {\r\n\t\t\t\t\t\talert('ok');\r\n\t\t\t\t\t\tif (param.intent) {\r\n\t\t\t\t\t\t\t// Daniel: The following calls return errors. Uncomment to clarify problem description.\r\n\t\t\t\t\t\t\t//alert(JSON.stringify(param.intent.getStringExtra(\"data\")));\r\n\t\t\t\t\t\t\t//alert(JSON.stringify(param.intent.getBlobExtra(\"data\")));\r\n\t\t\t\t\t\t}\r\n //vivekr : param.intent.getBlobExtra(\"data\") works\r\n var imageData = param.intent.getBlobExtra(\"data\"); \r\n\t\t\t\t\t\tvar image = Ti.UI.createImageView({\r\n\t\t\t\t\t\t\t// Daniel: Problem description uses this, but the function doesn't exist: \r\n\t\t\t\t\t\t\t// param.intent.getExtra(\"return-data\")\r\n\t\t\t\t\t\t\t// Andre: In my description, I meant that if I put the \"intent.putExtra(\"return-data\", true);\"\r\n\t\t\t\t\t\t\t// The result seems to come with data. If you remove this line, the result will be null\r\n\t\t\t\t\t\t\t// vivekr: This doesnt work - image : param.intent.data \r\n \r\n image : imageData,\r\n\t\t\t\t\t\t\twidth : 300,\r\n\t\t\t\t\t\t\theight : 300,\r\n\t\t\t\t\t\t\ttop : 0,\r\n\t\t\t\t\t\t\tleft : 0,\r\n\t\t\t\t\t\t\tbackgroundColor : '#FFF'\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\tvar newWin = Ti.UI.createWindow({\r\n\t\t\t\t\t\t\tbackgroundColor : '#000',\r\n\t\t\t\t\t\t\t//navBarHidden:true,\r\n\t\t\t\t\t\t\texitOnClose : true\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\tnewWin.add(image);\r\n\t\t\t\t\t\tnewWin.open();\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t\terror : function(error) {\r\n\t\t\t},\r\n\t\t\tcancel : function() {\r\n\t\t\t}\r\n\t\t});\r\n\t} catch(e) {\r\n\t}\r\n});\r\ncurWin.add(myView);\r\ncurWin.open();\r\n{code}", "attachment": [ { "id": "31560", "filename": "Code.js", "author": { "name": "andreperazzi", "key": "andreperazzi", "displayName": "André Perazzi", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-20T09:51:49.000+0000", "size": 2298, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "Android: Intent com.android.camera.action.CROP not returning data", "creator": { "name": "andreperazzi", "key": "andreperazzi", "displayName": "André Perazzi", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "andreperazzi", "key": "andreperazzi", "displayName": "André Perazzi", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "OS X 10.8.2, Titanium Studio 2.1.2, SDK 2.1.1.GA", "comment": { "comments": [ { "id": "220123", "author": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "André: If I understand correctly, you seem to have two separate problems with this code: one that startActivityForResult is not fired when navBarHidden is set to true, and one that the data result is null. Is that correct?\r\n\r\nFrom the comment you added in the code, did using \"param.intent.data\" fix the null problem?", "updateAuthor": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-21T09:13:43.000+0000", "updated": "2012-09-21T09:13:43.000+0000" }, { "id": "220130", "author": { "name": "andreperazzi", "key": "andreperazzi", "displayName": "André Perazzi", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Yes for the 1st question, but the navBarHidden:true is a known issue. That's not a problem for me. My real problem is that the data result is null, no matter what I do.\r\nBy adding \"intent.putExtra(\"return-data\", true);\" the problem is not fixed, but I can get the result 'Android.Graphics.Bitmap@' by calling \"param.intent.getStringExtra(\"data\"))\".\r\nNote that this data is a String, and not the image (object) itself.\r\n\r\nI can't find a way how to get the data object returned.", "updateAuthor": { "name": "andreperazzi", "key": "andreperazzi", "displayName": "André Perazzi", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-09-21T09:48:29.000+0000", "updated": "2012-09-21T09:48:29.000+0000" }, { "id": "229312", "author": { "name": "mlcunha", "key": "mlcunha", "displayName": "Marcio Cunha", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This bug makes almost impossible to crop an image on Androd, since Android has a lot of limitations such as pinch zoom, scrolling images in a scrollview (You can't put an image view in a scrollview when the image is actually bigger than the scrollview).\r\n\r\nHope this bug gets fixed soon.", "updateAuthor": { "name": "mlcunha", "key": "mlcunha", "displayName": "Marcio Cunha", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-11-30T15:42:43.000+0000", "updated": "2012-11-30T15:42:43.000+0000" }, { "id": "236113", "author": { "name": "vivekr", "key": "vivekr", "displayName": "Vivekr", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Working on it", "updateAuthor": { "name": "vivekr", "key": "vivekr", "displayName": "Vivekr", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-01-26T06:30:04.000+0000", "updated": "2013-01-26T06:30:04.000+0000" }, { "id": "236477", "author": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Pull pending\r\nhttps://github.com/appcelerator/titanium_mobile/pull/3814", "updateAuthor": { "name": "vduggal", "key": "vduggal", "displayName": "Vishal Duggal", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-01-29T19:25:38.000+0000", "updated": "2013-01-29T19:25:38.000+0000" }, { "id": "240499", "author": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Image is getting cropped as expected.\r\n\r\nVerified on : \r\nSDK version: 3.1.0.v20130303194855\r\nCLI version : 3.0.24\r\nAndroid : 3.2", "updateAuthor": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-03-04T06:25:47.000+0000", "updated": "2013-03-04T06:25:47.000+0000" }, { "id": "386367", "author": { "name": "astrovicapps", "key": "astrovicapps", "displayName": "Vittorio Sorbera", "active": true, "timeZone": "Europe/Berlin" }, "body": "I used this code on Ti SDK 5.2.2.GA:\r\n\r\n{code:java}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : '#ffffff',\r\n\texitOnClose : true\r\n});\r\nvar myView = Ti.UI.createView();\r\nvar curBtn = Ti.UI.createButton({\r\n\tcolor : '#000000',\r\n\ttitle : 'Select Photo',\r\n\theight : 'auto',\r\n\twidth : 'auto',\r\n\ttop : 10\r\n});\r\nvar imageView = Ti.UI.createImageView({\r\n\twidth : 200,\r\n\theight : 200,\r\n\tbackgroundColor : '#ccc'\r\n});\r\nmyView.add(curBtn);\r\nmyView.add(imageView);\r\n\r\ncurBtn.addEventListener('click', function(e) {\r\n\tif(!Titanium.Filesystem.hasStoragePermissions()) {\r\n\t\tif (Ti.Platform.Android.API_LEVEL >= 23) {\r\n\t\t\tTitanium.Filesystem.requestStoragePermissions(function(e) {\r\n\t\t\t\tif (e.success) {\r\n\t\t\t\t\topenPhotoGallery();\r\n\t\t\t\t} else {\r\n\t\t\t\t\talert(\"Need permissions\");\r\n\t\t\t\t};\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\topenPhotoGallery();\r\n\t\t};\r\n\t}else{\r\n\t\topenPhotoGallery();\r\n\t};\r\n});\r\n\r\nfunction openPhotoGallery(){\r\n\tTi.Media.openPhotoGallery({\r\n\t\tsuccess : function(event) {\t\t\t\t\r\n\t\t\tvar intent = Ti.Android.createIntent({\r\n\t\t\t\taction : \"com.android.camera.action.CROP\",\r\n\t\t\t\tdata : event.media.nativePath,\r\n\t\t\t\ttype : 'image/*'\r\n\t\t\t});\r\n\t\t\tintent.putExtra(\"scale\", true);\r\n\t\t\tintent.putExtra(\"return-data\", true);\r\n\t\t\tvar activity = win.getActivity();\r\n\t\t\tactivity.startActivityForResult(intent, function(param) {\t\t\t\t\t\r\n\t\t\t\tif (param.resultCode == Ti.Android.RESULT_OK) {\r\n\t\t\t\t\tif (param.intent) {\r\n\t\t\t\t\t\tvar imageData = param.intent.getBlobExtra(\"data\");\r\n\t\t\t\t\t\timageView.image = imageData;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t},\r\n\t\terror : function(error) {\r\n\t\t\t// error...\r\n\t\t},\r\n\t\tcancel : function() {\r\n\t\t\t// cancel...\r\n\t\t}\r\n\t});\r\n};\r\n\r\nwin.add(myView);\r\nwin.open();\r\n\r\n{code}\r\n\r\nIt seems to work for Android versions <6. But on Android 6 (API = 23) I get this error:\r\n\r\n\r\n{code:java}\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): Uncaught exception in background thread Thread[BackgroundTask #1,1,main]\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): java.lang.IllegalArgumentException: mediaStoreUri must be a MediaStore Uri\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat p.a(PG:5135)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat gqa.a(PG:230)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat got.b(PG:144)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat got.a(PG:2085)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat fgo.a(PG:44)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat gob.a(PG:49)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat mdb.e(PG:290)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat mdb.f(PG:304)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat mdr.run(PG:90)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat pci.run(PG:85)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)\r\n05-20 19:19:27.214: E/PhotosUEHandler(570): \tat java.lang.Thread.run(Thread.java:818)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): FATAL EXCEPTION: BackgroundTask #1\r\n05-20 19:19:27.236: E/AndroidRuntime(570): Process: com.google.android.apps.photos, PID: 570\r\n05-20 19:19:27.236: E/AndroidRuntime(570): java.lang.IllegalArgumentException: mediaStoreUri must be a MediaStore Uri\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat p.a(PG:5135)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat gqa.a(PG:230)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat got.b(PG:144)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat got.a(PG:2085)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat fgo.a(PG:44)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat gob.a(PG:49)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat mdb.e(PG:290)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat mdb.f(PG:304)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat mdr.run(PG:90)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat pci.run(PG:85)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)\r\n05-20 19:19:27.236: E/AndroidRuntime(570): \tat java.lang.Thread.run(Thread.java:818)\r\n{code}", "updateAuthor": { "name": "astrovicapps", "key": "astrovicapps", "displayName": "Vittorio Sorbera", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-20T17:56:38.000+0000", "updated": "2016-05-20T17:56:38.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }