Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1510] Android: Illegal invocation aliasing Titanium.Media.showCamera

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-09-29T01:44:10.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsandoid, camera
ReporterNick Sardo
AssigneeShak Hossain
Created2015-01-01T00:02:00.000+0000
Updated2016-03-08T07:37:57.000+0000

Description

Working through a book example that looks something like this: var photoSource = Titanium.Media.getIsCameraSupported() ? Titanium.Media.showCamera : Titanium.Media.openPhotoGallery; photoSource({object...}); This code execute find on iOS devices but throws an illegal invocation exception on android devices. This was my workaround: photoSource.call(Titanium.Media, { ...

Comments

  1. Shuo Liang 2015-01-05

    Hi, Not quite follow you case, please provide a simple test case to reproduce your problem. Thanks Regards, Shuo
  2. Nick Sardo 2015-01-05

    // feed.js controller var args = arguments[0] || {}; OS_IOS && $.cameraButton.addEventListener("click", function(_event){ $.cameraButtonClicked(_event); }); $.cameraButtonClicked = function(_event) { var photoSource = Titanium.Media.getIsCameraSupported() ? Titanium.Media.showCamera : Titanium.Media.openPhotoGallery; // this call will throw an illegal invocation error on Android photoSource({ success: function(event){ processImage(event.media, function(photoResp){ // create row var row = Alloy.createController('feedRow', photoResp); // add the controller view, which is a row to the table if ($.feedTable.getData().length === 0) { $.feedTable.setData([]); $.feedTable.appendRow(row.getView(), true); } else { $.feedTable.insertRowBefore(0, row.getView(), true); } }); }, cancel: function() { // called when user cancels taking a picture }, error: function(error) { if(error.code == Ti.Media.NO_CAMERA) alert('Please run this test on a device'); else alert('Unexpected error: ' + error.code); }, saveToPhotoGallery:false, allowEditing: true, // only alow for photos no videa mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO] }); }; function processImage(_mediaObject, _callback) { // since there is no cloud integration we will fake it var photoObject = { image: _mediaObject, title: "Sample Photo " + new Date() }; // return obj to caller _callback(photoObject); };
  3. Harish Mridha 2015-09-03

    Hi , I tested the issue you reported.It looks like the feature "*Titanium.Media.showCamera* and *Titanium.Media.getIsCameraSupported* " in Android is working fine for me .I can't reproduce it . However, feel free to reopen with additional information such as proper description , test case and steps to reproduce a if you notice otherwise.I also recommend you upgrade SDK and Alloy to the latest build and let us know if you get the error again. I tested this using the studio build: 4.1.1.201507141126 , TiSDK 4.1.0 GA and alloy -v 1.6.2 Thanks

JSON Source