{ "id": "159651", "key": "TIMOB-23230", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": "16980", "description": "New V8", "name": "Release 6.0.0", "archived": false, "released": true, "releaseDate": "2016-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-06-03T02:40:38.000+0000", "created": "2016-04-18T18:13:03.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "Camera", "Media" ], "versions": [], "issuelinks": [ { "id": "51941", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "160738", "key": "TIMOB-23473", "fields": { "summary": "Android: Getting an error in the logs when using the Camera (Regression)", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-08-06T17:49:20.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": "10224", "name": "TiAPI", "description": "This component is used for cross-platform API work. Specifications are most likely to use this component." } ], "description": "h6.description\r\nSuppose we have an app that automatically takes photos. At the moment what I do is invoke \"Ti.Media.showCamera\" then wait 2 seconds and then invoke Ti.Media.takePicture. \r\n\r\nBut some devices take some time to open the camera. So the app is crashed when \"Ti.Media.takePicture\" is called before opening the camera.\r\n\r\nSo the better way to know if the camera has been opened successfully using an event? \r\n\r\nI am not sure about the native behaviour.", "attachment": [], "flagged": false, "summary": "iOS,Android: An event for the camera has been opened successfully.", "creator": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "subtasks": [], "reporter": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "environment": null, "closedSprints": [ { "id": 641, "state": "closed", "name": "2016 Sprint 12 SDK", "startDate": "2016-06-04T00:30:28.612Z", "endDate": "2016-06-18T00:30:00.000Z", "completeDate": "2016-06-20T04:25:16.065Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "384261", "author": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "There is no event for when the camera has opened and it cannot be added without subclassing the UIImagePickerController. However, you can listen out for the [paused event|https://docs.appcelerator.com/platform/latest/#!/api/Titanium.App-event-paused] it will get fired once the application enters the background. You can take the picture inside that event, i would add a delay of a second just to avoid possible crashes. ", "updateAuthor": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-04-28T22:04:59.000+0000", "updated": "2016-04-28T22:04:59.000+0000" }, { "id": "385184", "author": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "[~apetkov], \r\n\r\n\"paused\" event only Fired when the application transitions to the background on a multitasked system. So if the application goes to the background then how can we take picture? We need event when the camera has opened successfully. So I think, that is not fit here. Now as a workaround we are using delay function \"setTimeout\". So when we can get this feature? This is needed for both android and iOS\r\n\r\nThanks.", "updateAuthor": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2016-05-09T20:42:28.000+0000", "updated": "2016-05-09T20:45:15.000+0000" }, { "id": "385323", "author": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello, yeah you're right adding the pause or paused event will not work, as they do not get executed once the camera overlays the application which i thought it would, as you can execute commands as the application enters the background. I've looked in to this issue more, there is no delegates for when the camera is opened so i cannot create an js callback event.\r\n\r\nI will think about this more and give an update soon, for the movement i cannot think of ways to implement this feature with good practices. ", "updateAuthor": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-05-10T19:52:16.000+0000", "updated": "2016-05-10T19:52:16.000+0000" }, { "id": "387461", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "To clarify, \"takePicture()\" is only used when the camera has overlay. On Android, we have our own activity to control the overlay, so this can be done.", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-06-02T21:34:44.000+0000", "updated": "2016-06-02T21:34:44.000+0000" }, { "id": "387464", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Android PR: https://github.com/appcelerator/titanium_mobile/pull/8039", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-06-02T22:47:02.000+0000", "updated": "2016-06-02T22:47:02.000+0000" }, { "id": "387469", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Testing code:\r\n{code}\r\nvar window = Ti.UI.createWindow();\r\nvar overlay = Ti.UI.createView();\r\nvar button = Titanium.UI.createButton({\r\n\tcolor : '#fff',\r\n\tbottom : \"10dp\",\r\n\twidth : \"130dp\",\r\n\theight : \"50dp\",\r\n\tfont : {\r\n\t\tfontSize : \"14dp\",\r\n\t\tfontWeight : 'bold',\r\n\t\tfontFamily : 'Helvetica Neue'\r\n\t},\r\n\ttitle : 'Take Picture'\r\n});\r\n\r\nbutton.addEventListener('click', function() {\r\n\tTi.Media.takePicture();\r\n});\r\n\r\nwindow.add(overlay);\r\noverlay.add(button);\r\nwindow.addEventListener('open', function(e){\r\n var cameraPermission = \"android.permission.CAMERA\";\r\n var storagePermission = \"android.permission.READ_EXTERNAL_STORAGE\";\r\n var hasCameraPerm = Ti.Android.hasPermission(cameraPermission);\r\n var hasStoragePerm = Ti.Android.hasPermission(storagePermission);\r\n var permissionsToRequest = [];\r\n if (!hasCameraPerm) {\r\n \tpermissionsToRequest.push(cameraPermission);\r\n }\r\n if (!hasStoragePerm) {\r\n \tpermissionsToRequest.push(storagePermission);\r\n }\r\n if (permissionsToRequest.length > 0) {\r\n \tTi.Android.requestPermissions(permissionsToRequest, function(e) {\r\n \tif (e.success) {\r\n \t\tshowCamera();\r\n \t} else {\r\n \t\tTi.API.info(\"ERROR: \" + e.error);\r\n \t}\r\n \t});\r\n } else {\r\n \t\tshowCamera();\r\n }\r\n});\r\nTi.Media.addEventListener('cameraready', function(e){\r\n Ti.Media.takePicture();\r\n})\r\nvar container = Ti.UI.createView({\r\n top:'10%',\r\n height:'80%'\r\n });\r\n\r\nvar img = Ti.UI.createImageView({\r\n });\r\n\r\ncontainer.add(img);\r\nwindow.add(container);\r\nwindow.open();\r\n\r\nfunction showCamera() {\r\n Ti.Media.showCamera({\r\n success : function(e) {\r\n Ti.API.info('GOT SUCCESS CALLBACK');\r\n var imgWid = e.media.width;\r\n var imgHeight = e.media.height;\r\n var mSize = container.size;\r\n var mW = mSize.width;\r\n var mH = mSize.height;\r\n\r\n var wS = imgWid/mW;\r\n var hS = imgHeight/mH;\r\n var tS = (wS < hS) ? wS : hS;\r\n\r\n var dstWid = imgWid/tS;\r\n var dstHeight = imgHeight/ tS;\r\n\r\n Ti.API.info(imgWid+' '+imgHeight+' '+mW+' '+mH+' '+wS+' '+hS+' '+tS+' '+dstWid+' '+dstHeight);\r\n var resize = e.media.imageAsResized(dstWid,dstHeight);\r\n img.image = resize;\r\n },\r\n\t overlay : overlay,\r\n\t mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],\r\n\t saveToPhotoGallery : true\r\n });\r\n}\r\n{code}\r\n\r\n1. Run code, should take picture automatically.", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-06-02T23:28:56.000+0000", "updated": "2016-06-02T23:28:56.000+0000" }, { "id": "387478", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Android PR has been reviewed and merged into master for Release 6.0.0.\r\nhttps://github.com/appcelerator/titanium_mobile/pull/8039", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-06-03T02:40:31.000+0000", "updated": "2016-06-03T02:42:03.000+0000" }, { "id": "387544", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "iOS does not provide an API for checking if the camera was focussed. I would place it in {{-(void)displayModalPicker:(UIViewController*)picker_ settings:(NSDictionary*)args}}, but that is only the place where it starts opening so not good enough. Besides that, I never saw an application crashing on iOS, so the issue might only affect Android.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-06-03T19:53:23.000+0000", "updated": "2016-06-03T19:54:25.000+0000" }, { "id": "387683", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The event is not just to prevent a crash, but to make sure takePicture() takes a picture, instead of doing nothing because the camera is not ready.", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-06-06T20:00:32.000+0000", "updated": "2016-06-06T20:00:32.000+0000" }, { "id": "398138", "author": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I verified that the fix works on this environment:\r\nNPM Version: 2.15.9\r\nNode Version: 4.5.0\r\nMac OS: 10.11.6\r\nAppc CLI: 5.5.0\r\nAppc CLI NPM: 4.2.7\r\nTitanium SDK version: 6.0.0.v20161002235150\r\nAppcelerator Studio, build: 4.8.0.201609290836\r\nXcode 8.0 GM\r\n\r\nI verified the fix on two different Android devices (5.1.1 and 6.0). I opened and closed the app 10 times using the demo code, and a picture was taken consistently each time.\r\n\r\n[~apetkov] you had noted that you will create a new ticket for iOS. Can you confirm if there is a new ticket for iOS? I will then close this one. ", "updateAuthor": { "name": "amukherjee", "key": "amukherjee", "displayName": "Abir Mukherjee", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-10-05T16:28:43.000+0000", "updated": "2016-10-05T16:28:43.000+0000" }, { "id": "440119", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-06T17:49:20.000+0000", "updated": "2018-08-06T17:49:20.000+0000" } ], "maxResults": 14, "total": 14, "startAt": 0 } } }