2013-07-30 2 views
-3

Android 앱을 처음 사용했지만 여러 가지 방법으로 카메라 앱을 사용해 보았습니다.android에서 앱을 사용하여 카메라 작성하기

나는 5 분마다 사진을 찍어 내 서버로 보내고 싶지만, 시도한 각 방법은 나에게 셔터를 누르기를 기대하는 내장 카메라 앱을 제공하는 앱으로 나를 공급하게된다. 이게 자동으로 필요합니다.

코르도바에서 '래퍼'가 수행합니다. 안드로이드 개발자 페이지에있는 예제가 이것을 수행하며 안드로이드 프로그래밍 북을 통해 카메라 pp 예제가 똑같이 작동한다는 사실에 의혹을 느낍니다.

+1

질문이 있으십니까? "코드를 알려주세요"이외는? – Simon

답변

0
//somewhere in your code call this (Maybe you need to set up a timer): 
mCamera.takePicture(null, null, mCall); 

//this should be done before using camera 
Camera mCamera; 
private boolean safeCameraOpen(int id) { 
boolean qOpened = false; 

    try { 
     releaseCamera(); 
     mCamera = Camera.open(id); 
     qOpened = (mCamera != null); 
    } catch (Exception e) { 
     Log.e(getString(R.string.app_name), "failed to open Camera"); 
     e.printStackTrace(); 
    } 

    return qOpened;  
} 

private void releaseCamera() { 
    if (mCamera != null) { 
     mCamera.release(); 
     mCamera = null; 
    } 
} 

Camera.PictureCallback mCall = new Camera.PictureCallback() { 

    // you need to change this method due to your needs 
    public void onPictureTaken(byte[] data, Camera camera) { 
     //decode the data obtained by the camera into a Bitmap 

     FileOutputStream outStream = null; 
       try { 
        outStream = new FileOutputStream("/sdcard/Image.jpg"); 
        outStream.write(data); 
        outStream.close(); 
       } catch (FileNotFoundException e){ 
        Log.d("CAMERA", e.getMessage()); 
       } catch (IOException e){ 
        Log.d("CAMERA", e.getMessage()); 
       } 

    } 
}; 
관련 문제