2014-04-30 2 views
3

camera plugin을 조정하여 내 장치에서 지원할 수있는 카메라 해상도를 찾았습니다. 다음은 CameraLauncher.java의 테이크 픽쳐 함수입니다.코르도바 : 카메라 플러그인을 조정하면 앱과 카메라가 충돌합니다.

/** 
* Take a picture with the camera. 
* When an image is captured or the camera view is cancelled, the result is returned 
* in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult. 
* 
* The image can either be returned as a base64 string or a URI that points to the file. 
* To display base64 string in an img tag, set the source to: 
*  img.src="data:image/jpeg;base64,"+result; 
* or to display URI in an img tag 
*  img.src=result; 
* 
* @param quality   Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) 
* @param returnType  Set the type of image to return. 
*/ 
public void takePicture(int returnType, int encodingType) { 



    // **********TWEAK************* // 

    camera = Camera.open(0); 
    Camera.Parameters params = camera.getParameters(); 
    List<Camera.Size> sizes = params.getSupportedPictureSizes(); 
    Camera.Size result = null; 

    for (int i=0;i<sizes.size();i++){ 
     result = sizes.get(i); 
     Log.i("*********PictureSize************", "Supported Size. Width: " + result.width + "height : " + result.height); 
    } 


    // ********TWEAK ENDS********* // 



    // Save the number of images currently on disk for later 
    this.numPics = queryImgDB(whichContentStore()).getCount(); 

    // Display camera 
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); 

    // Specify file so that large image is captured and returned 
    File photo = createCaptureFile(encodingType); 
    intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); 

    this.imageUri = Uri.fromFile(photo);  

    if (this.cordova != null) { 
     this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); 
    } 
    else 
     LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity"); 
} 

내 트윅이 효과적입니다. 그것은 내 장치가 지원하는 모든 가능한 해결책을 나열했습니다. 그러나 사진을 찍기 위해 카메라가 열리면 카메라 (및 내 앱)가 '카메라 오류'라는 경고 메시지와 충돌합니다. 이 메시지는 다른 장치에 따라 다릅니다. 예를 들어 Karbonn 타블렛 (중국 하드웨어)에서 '불행히도 카메라가 추락했습니다.'라는 메시지가 나타납니다. 나는 무슨 일이 벌어지고 있는지 전혀 모른다. 내 비틀기를 제거하면 카메라가 정상적으로 작동합니다.

도와주세요.

다음은 로그 캣 콘솔입니다 :

04-30 15:57:05.815: D/dalvikvm(2598): Late-enabling CheckJNI 
04-30 15:57:06.115: I/CordovaLog(2598): Changing log level to DEBUG(3) 
04-30 15:57:06.115: I/CordovaLog(2598): Found start page location: index.html 
04-30 15:57:06.115: D/Whitelist(2598): Unlimited access to network resources 
04-30 15:57:06.125: D/CordovaActivity(2598): CordovaActivity.onCreate() 
04-30 15:57:06.155: I/dalvikvm(2598): Could not find method org.apache.cordova.CordovaWebView.setWebContentsDebuggingEnabled, referenced from method org.apache.cordova.CordovaWebView.setup 
04-30 15:57:06.155: W/dalvikvm(2598): VFY: unable to resolve static method 2439: Lorg/apache/cordova/CordovaWebView;.setWebContentsDebuggingEnabled (Z)V 
04-30 15:57:06.155: D/dalvikvm(2598): VFY: replacing opcode 0x71 at 0x00be 
04-30 15:57:06.265: D/CordovaWebView(2598): CordovaWebView is running on device made by: Karbonn 
04-30 15:57:06.285: D/JsMessageQueue(2598): Set native->JS mode to 2 
04-30 15:57:06.285: I/CordovaWebView(2598): Disabled addJavascriptInterface() bridge since Android version is old. 
04-30 15:57:06.285: D/CordovaActivity(2598): CordovaActivity.init() 
04-30 15:57:06.315: D/CordovaWebView(2598): >>> loadUrl(file:///android_asset/www/index.html) 
04-30 15:57:06.315: D/PluginManager(2598): init() 
04-30 15:57:06.365: D/CordovaWebView(2598): >>> loadUrlNow() 
04-30 15:57:06.365: I/CordovaLog(2598): Changing log level to DEBUG(3) 
04-30 15:57:06.365: I/CordovaLog(2598): Found start page location: index.html 
04-30 15:57:06.365: D/Whitelist(2598): Unlimited access to network resources 
04-30 15:57:06.365: D/CordovaActivity(2598): Resuming the App 
04-30 15:57:06.365: D/CordovaActivity(2598): CB-3064: The errorUrl is null 
04-30 15:57:06.385: D/ViewRootImpl(2598): pckname = com.jadesync.travelguide 
04-30 15:57:06.395: I/dalvikvm(2598): threadid=3: reacting to signal 3 
04-30 15:57:06.425: D/SoftKeyboardDetect(2598): Ignore this event 
04-30 15:57:06.425: I/dalvikvm(2598): Wrote stack traces to '/data/anr/traces.txt' 
04-30 15:57:06.485: D/libEGL(2598): loaded /system/lib/egl/libEGL_mali.so 
04-30 15:57:06.555: D/libEGL(2598): loaded /system/lib/egl/libGLESv1_CM_mali.so 
04-30 15:57:06.565: D/libEGL(2598): loaded /system/lib/egl/libGLESv2_mali.so 
04-30 15:57:06.615: D/OpenGLRenderer(2598): Enabling debug mode 0 
04-30 15:57:06.645: D/SoftKeyboardDetect(2598): Ignore this event 
04-30 15:57:06.715: D/CordovaActivity(2598): onMessage(onPageStarted,file:///android_asset/www/index.html) 
04-30 15:57:07.055: D/dalvikvm(2598): GC_CONCURRENT freed 124K, 3% free 6869K/7047K, paused 2ms+6ms 
04-30 15:57:08.675: D/CordovaLog(2598): file:///android_asset/www/cordova.js: Line 966 : Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. 
04-30 15:57:08.675: I/Web Console(2598): Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. at file:///android_asset/www/cordova.js:966 
04-30 15:57:09.585: D/dalvikvm(2598): GC_CONCURRENT freed 24K, 3% free 7253K/7431K, paused 2ms+9ms 
04-30 15:57:09.615: D/CordovaWebViewClient(2598): onPageFinished(file:///android_asset/www/index.html) 
04-30 15:57:09.615: D/CordovaActivity(2598): onMessage(onPageFinished,file:///android_asset/www/index.html) 
04-30 15:57:09.725: D/dalvikvm(2598): GC_FOR_ALLOC freed 11K, 3% free 7641K/7815K, paused 34ms 
04-30 15:57:09.795: D/dalvikvm(2598): GC_FOR_ALLOC freed 9K, 3% free 8025K/8199K, paused 33ms 
04-30 15:57:10.005: D/CordovaActivity(2598): onMessage(spinner,stop) 
04-30 15:57:10.055: D/CordovaNetworkManager(2598): Connection Type: wifi 
04-30 15:57:10.065: D/CordovaNetworkManager(2598): Connection Type: wifi 
04-30 15:57:10.065: D/CordovaActivity(2598): onMessage(networkconnection,wifi) 
04-30 15:57:11.625: D/CordovaActivity(2598): onMessage(spinner,stop) 
04-30 15:57:19.155: D/CordovaWebViewClient(2598): onPageFinished(file:///android_asset/www/index.html#&ui-state=dialog) 
04-30 15:57:19.155: D/CordovaActivity(2598): onMessage(onPageFinished,file:///android_asset/www/index.html#&ui-state=dialog) 
04-30 15:57:24.555: D/SoftKeyboardDetect(2598): Ignore this event 
04-30 15:57:25.455: D/SoftKeyboardDetect(2598): Ignore this event 
04-30 15:57:28.465: D/SoftKeyboardDetect(2598): Ignore this event 
04-30 15:57:31.005: D/SoftKeyboardDetect(2598): Ignore this event 
04-30 15:57:31.105: W/webcoreglue(2598): updateFrameCache: pending style recalc, ignoring. 
04-30 15:57:33.275: D/SoftKeyboardDetect(2598): Ignore this event 
04-30 15:57:33.395: D/SoftKeyboardDetect(2598): Ignore this event 
04-30 15:57:36.855: D/CordovaLog(2598): file:///android_asset/www/js/custom_script.js: Line 120 : success 
04-30 15:57:36.855: I/Web Console(2598): success at file:///android_asset/www/js/custom_script.js:120 
04-30 15:57:36.925: D/CordovaWebViewClient(2598): onPageFinished(file:///android_asset/www/index.html#/android_asset/www/index.html) 
04-30 15:57:36.925: D/CordovaActivity(2598): onMessage(onPageFinished,file:///android_asset/www/index.html#/android_asset/www/index.html) 
04-30 15:57:40.335: D/CordovaWebViewClient(2598): onPageFinished(file:///android_asset/www/index.html#view-my-packages) 
04-30 15:57:40.335: D/CordovaActivity(2598): onMessage(onPageFinished,file:///android_asset/www/index.html#view-my-packages) 
04-30 15:57:40.495: D/CordovaLog(2598): file:///android_asset/www/js/custom_script.js: Line 415 : [object Object] 
04-30 15:57:40.495: I/Web Console(2598): [object Object] at file:///android_asset/www/js/custom_script.js:415 
04-30 15:58:00.155: D/CordovaWebViewClient(2598): onPageFinished(file:///android_asset/www/index.html#view-my-packages&ui-state=dialog) 
04-30 15:58:00.155: D/CordovaActivity(2598): onMessage(onPageFinished,file:///android_asset/www/index.html#view-my-packages&ui-state=dialog) 
04-30 15:58:05.415: D/CordovaLog(2598): file:///android_asset/www/js/custom_script.js: Line 232 : Capture image 
04-30 15:58:05.415: I/Web Console(2598): Capture image at file:///android_asset/www/js/custom_script.js:232 
04-30 15:58:06.555: I/*********PictureSize************(2598): Supported Size. Width: 1280height : 1024 
04-30 15:58:06.555: I/*********PictureSize************(2598): Supported Size. Width: 640height : 480 
04-30 15:58:06.615: W/PluginManager(2598): THREAD WARNING: exec() call to Camera.takePicture blocked the main thread for 1192ms. Plugin should use CordovaInterface.getThreadPool(). 
04-30 15:58:06.625: D/CordovaActivity(2598): Paused the application! 
04-30 15:58:06.625: D/CordovaWebView(2598): Handle the pause 
04-30 15:58:06.705: D/OpenGLRenderer(2598): Flushing caches (mode 1) 
04-30 15:58:06.735: D/OpenGLRenderer(2598): Flushing caches (mode 0) 
04-30 15:58:07.555: D/CordovaActivity(2598): CordovaActivity.onDestroy() 
04-30 15:58:07.625: D/CordovaWebView(2598): >>> loadUrlNow() 
04-30 15:58:07.655: D/CordovaActivity(2598): onMessage(onPageStarted,about:blank) 
04-30 15:58:07.695: D/CordovaWebViewClient(2598): onPageFinished(about:blank) 
04-30 15:58:07.695: D/CordovaActivity(2598): onMessage(onPageFinished,about:blank) 
04-30 15:58:07.695: D/CordovaActivity(2598): onMessage(exit,null) 

답변

1

해결!

내 옆에서 아주 바보 같은 실수 ... 나는 결코 카메라를 출시하지 않았습니다. - camera.release();

는 희망이 도움이 사람이

을 :)

// **********TWEAK************* // 

    camera = Camera.open(0); 
    Camera.Parameters params = camera.getParameters(); 
    List<Camera.Size> sizes = params.getSupportedPictureSizes(); 
    Camera.Size result = null; 

    for (int i=0;i<sizes.size();i++){ 
     result = sizes.get(i); 
     Log.i("*********PictureSize************", "Supported Size. Width: " + result.width + "height : " + result.height); 
    } 

    camera.release(); 


// ********TWEAK ENDS********* // 

노트 마지막 함수 호출 :

여기에 올바른 코드입니다

관련 문제