[TIMOB-23795] Hyperloop - Android: Using Camera2 API CameraManager not working
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Hyperloop |
Labels | android, camera, engTriage, hyperloop |
Reporter | Michael Gangolf |
Assignee | Jan Vennemann |
Created | 2016-08-19T18:49:25.000+0000 |
Updated | 2019-11-19T15:52:46.000+0000 |
Description
Trying to use the Android Camera2 API CameraManager fails with this error message:
Message: Uncaught TypeError: Object android.hardware.camera2.CameraManager@436cda3 has no method 'getCameraIdList'
*Code:*
var Activity = require('android.app.Activity');
var Context = require("android.content.Context");
var activity = new Activity(Titanium.App.Android.getTopActivity());
var CameraManager = require("android.hardware.camera2.CameraManager");
var cameraManager = activity.getSystemService(CameraManager.class);
console.log("CameraManager: " + cameraManager);
if (cameraManager !== null) {
var cameraIdList = cameraManager.getCameraIdList();
console.log("CameraIDs: " + JSON.stringify(cameraIdList));
}
var cameraManager = activity.getSystemService(Context.CAMERA_SERVICE);
console.log("CameraManager: " + cameraManager);
if (cameraManager !== null) {
var cameraIdList = cameraManager.getCameraIdList();
console.log("CameraIDs: " + JSON.stringify(cameraIdList));
}
Android 6.0.1
Titanium 5.4.0
Moving to TIMOB. Does it work to supply the class as a String (e.g.
"CameraManager"
instead ofCameraManager.class
)? That's at least how it's done on iOS. Otherwise it's a use-case we didn't cover, yet.I'll the string version. The fingerprint android example https://github.com/appcelerator/hyperloop-examples/blob/master/app/controllers/android/touchid.js uses the .class syntax so I've adopted that
[~michael] I think the following is the correct call:
but it might not be called because the previous call returns something non-null that is still not able to handle
getCameraIdList
. So can you try to just call the second option? I'm just wondering why this specific class would not work, but others do. Thanks!Just using this:
will still show: {noformat} [INFO] CameraManager: android.hardware.camera2.CameraManager@2f69c118 [ERROR] TiExceptionHandler: (main) [1341,1341] ----- Titanium Javascript Runtime Error ----- [ERROR] TiExceptionHandler: (main) [0,1341] - In alloy/controllers/index.js:44,42 [ERROR] TiExceptionHandler: (main) [0,1341] - Message: Uncaught TypeError: Object android.hardware.camera2.CameraManager@2f69c118 has no method 'getCameraIdList' [ERROR] TiExceptionHandler: (main) [1,1342] - Source: var cameraIdList = cameraManager.getCameraIdList(); [ERROR] V8Exception: Exception occurred at alloy/controllers/index.js:44: Uncaught TypeError: Object android.hardware.camera2.CameraManager@2f69c118 has no method 'getCameraIdList' {noformat} A side note: I was using hyperloop 1.2.0 before and just found out, that it skipped the update to 1.2.7 everytime. When I removed the old 1.2.0 folder and run appc new again it successfully downloaded 1.2.7. But the error above is still with the latest version!
Still the same with Hyperloop 2.1.0
Hi @Michael, did you have success using Hyperloop with Camera2 API? We are looking for going this way since we need better compression on newer Android models (that capture 4k by default).
[~ygbr] no, not yet. Same error with Hyperloop 4.0.4. It might work fine creating a normal module. For me it was just a test so I didn't bother