Hi.
I want to show the Camera inside my app. Since I am not able to do it using Corona SDK, I am trying to use CoronaCards.
For some reason, I am not getting permission to access the camera, even with the permission already being required inside the manifest.
Here is the output log:
05-01 18:03:51.027: I/Corona(13026): Corona: Going to call Runtime:dispatchEvent( event ) 05-01 18:03:51.035: I/System.out(13026): Corona Show Camera please! 05-01 18:03:51.035: I/System.out(13026): on getCameraInstace 05-01 18:03:51.035: I/System.out(13026): Trying to open Camera 05-01 18:03:51.039: W/ServiceManager(87): Permission failure: android.permission.CAMERA from uid=10082 pid=13026 05-01 18:03:51.039: E/CameraService(87): Permission Denial: can't use the camera pid=13026, uid=10082 05-01 18:03:51.039: I/System.out(13026): Error accessing the camerajava.lang.RuntimeException: Fail to connect to camera service
Corona code:
-- Calling native Android Camera local event = { name="coronaView", message=" Show Camera please!" } print("Corona: Going to call Runtime:dispatchEvent( event )"); -- Dispatch the event to the global Runtime object local result = Runtime:dispatchEvent( event ) print( "Corona: Response: " .. result ) --\> Response: Nice to meet you CoronaCards!
Android code (MainActivity.java):
(some code before) ... ... mBigCoronaView.setCoronaEventListener(new CoronaEventListener() { @Override public Object onReceivedCoronaEvent(CoronaView view, Hashtable\<Object, Object\> event) { System.out.println("Corona" + event.get("message")); showCameraOnScreen(rootView); return "Nice to meet you CoronaCards!"; } }); return rootView; } /\*\* A safe way to get an instance of the Camera object. \*/ public static Camera getCameraInstance(int cameraID){ System.out.println("on getCameraInstace"); Camera c = null; try { System.out.println("Trying to open Camera"); c = Camera.open(cameraID); System.out.println("Camera opened"); } catch (Exception e) { // Camera is not available (in use or does not exist) System.out.println("Error accessing the camera" + e.toString()); } return c; // returns null if camera is unavailable }
AndroidManifest.xml
\<?xml version="1.0" encoding="utf-8"?\> \<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.guarana.card" android:versionCode="1" android:versionName="1.0" \> \<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" /\> \<uses-feature android:name="android.hardware.screen.portrait" android:required="true" /\> \<uses-feature android:name="android.hardware.screen.landscape" android:required="false" /\> \<uses-feature android:name="android.hardware.camera" android:required="true" /\> \<uses-feature android:name="android.hardware.camera.front" android:required="true" /\> \<uses-feature android:name="android.hardware.camera.any" android:required="true" /\> \<application android:allowBackup="true" android:icon="@drawable/ic\_launcher" android:label="@string/app\_name" android:theme="@style/AppTheme" \> \<activity android:name="com.example.coronacard.MainActivity" android:label="@string/app\_name" android:screenOrientation="portrait" \> \<intent-filter\> \<action android:name="android.intent.action.MAIN" /\> \<category android:name="android.intent.category.LAUNCHER" /\> \</intent-filter\> \</activity\> \</application\> \</manifest\>