ZXING интеграция - ошибка камеры - PullRequest
1 голос
/ 01 марта 2012

Я работаю над приложением для Android с интеграцией сканера штрих-кода zxing.это предварительный просмотр камеры с кнопкой, которая запускает сканер штрих-кода.( Я использовал это )

Приложение работает нормально, но только первое сканирование.Когда я хочу сделать еще одно сканирование: происходит ошибка камеры: снимок экрана здесь

Когда я перезагружаю телефон, снова работает только первое сканирование.

Кто-нибудь может помочь, пожалуйста?новичок (извините за мой английский)

**class Preview**

   @Override
   public void surfaceCreated(SurfaceHolder holder) {

           camera = Camera.open();


   }



   @Override
   public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {
       if (previewing) { 
           camera.stopPreview();
           camera.setPreviewCallback(null);
           previewing=false;


       }
     try {
           camera.setPreviewDisplay(holder);
           camera.startPreview();
           previewing = true;
       } catch(Exception e) {

       }

   }




   @Override
   public void surfaceDestroyed(SurfaceHolder holder) {
       if (camera != null) {
           camera.stopPreview();
           camera.setPreviewCallback(null);
           camera.release();
           camera = null;
           previewing=false;
       }
   }

}

Класс оверлея

public class Overlay extends Activity { 

   Button mScan;
   String text="";
   LayoutInflater controlInflater = null;


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
          super.onCreate(savedInstanceState); 

          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
          this.requestWindowFeature(Window.FEATURE_NO_TITLE);
          this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


          getWindow().setFormat(PixelFormat.UNKNOWN);       

          Preview mPreview = new Preview(this); 
          setContentView(mPreview); 

          controlInflater = LayoutInflater.from(getBaseContext());
          View viewControl = controlInflater.inflate(R.layout.main, null);

          LayoutParams layoutParamsControl = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
          this.addContentView(viewControl, layoutParamsControl);


          Button bscan = (Button)findViewById(R.id.mScan);
          bscan.setOnClickListener(new Button.OnClickListener(){
              public void onClick(View v) {
                  IntentIntegrator integrator = new IntentIntegrator(Overlay.this);
                  integrator.initiateScan(IntentIntegrator.QR_CODE_TYPES);
                }
              });              
   } 

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) { // Handle successful scan
                String contents = intent.getStringExtra("SCAN_RESULT");
               // String format = intent.getStringExtra("SCAN_RESULT_FORMAT");


                text=contents;      
                Toast.makeText(Overlay.this,"Nacitane data: " + contents, Toast.LENGTH_LONG).show();

            } else if (resultCode == RESULT_CANCELED) {// Handle cancel

            }
        }
    }



}

LOGCAT:

запуск приложения:

03-06 14:44:53.489: I/ActivityManager(164): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=martin.android/.Overlay} from pid 375
03-06 14:44:53.563: D/dalvikvm(1582): Late-enabling CheckJNI
03-06 14:44:53.575: I/ActivityManager(164): Start proc martin.android for activity martin.android/.Overlay: pid=1582 uid=10065 gids={1006}
03-06 14:44:53.676: I/InputReader(164): Reconfiguring input devices.  changes=0x00000004
03-06 14:44:53.676: I/InputReader(164): Device reconfigured: id=6, name='mxt224_ts_input', surface size is now 480x800, mode is 1
03-06 14:44:53.696: I/ActivityManager(164): Config changed: {1.0 231mcc6mnc en_GB layoutdir=0 sw320dp w533dp h294dp nrml long land finger -keyb/v/h -nav/h s.5}
03-06 14:44:53.907: D/libEGL(1582): loaded /system/lib/egl/libGLES_android.so
03-06 14:44:53.918: D/libEGL(1582): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
03-06 14:44:53.926: D/libEGL(1582): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
03-06 14:44:53.930: D/libEGL(1582): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
03-06 14:44:53.965: D/dalvikvm(238): GC_FOR_ALLOC freed 349K, 30% free 9925K/14151K, paused 42ms
03-06 14:44:54.008: D/dalvikvm(238): GC_FOR_ALLOC freed 189K, 30% free 10039K/14151K, paused 35ms
03-06 14:44:54.071: D/OpenGLRenderer(1582): Enabling debug mode 0
03-06 14:44:54.094: I/CameraService(81): Opening camera 0
03-06 14:44:54.098: I/CameraHardwareSec(81): int android::HAL_camera_device_open(const hw_module_t*, const char*, hw_device_t**): open camera 0
03-06 14:44:54.102: E/SecCamera(81): initCamera: m_cam_fd(28), m_jpeg_fd(0)
03-06 14:44:54.102: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:44:54.118: E/SecCamera(81): initCamera: m_cam_fd2(29)
03-06 14:44:54.118: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:44:54.118: I/SecCamera(81): initCamera : initialized
03-06 14:44:54.118: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:44:54.118: I/CameraHardwareSec(81): int android::HAL_camera_device_open(const hw_module_t*, const char*, hw_device_t**): opened camera 0 (0x144d2f0)
03-06 14:44:54.121: I/AwesomePlayer(81): setDataSource_l('/system/media/audio/ui/camera_click.ogg')
03-06 14:44:54.125: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): starting
03-06 14:44:54.125: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): calling mSecCamera->stopPreview() and waiting
03-06 14:44:54.125: W/SecCamera(81): int android::SecCamera::stopPreview(): doing nothing because m_flag_camera_start is zero
03-06 14:44:54.149: D/OpenGLRenderer(375): Flushing caches (mode 1)
03-06 14:44:54.149: I/AwesomePlayer(81): setDataSource_l('/system/media/audio/ui/VideoRecord.ogg')
03-06 14:44:54.340: D/OpenGLRenderer(375): Flushing caches (mode 0)
03-06 14:44:54.399: D/OpenGLRenderer(375): Flushing caches (mode 0)
03-06 14:44:54.996: D/CameraHardwareSec(81): mPreviewHeap(fd(28), size(518400), width(720), height(480))
03-06 14:44:55.000: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): return from wait
03-06 14:44:55.086: I/ActivityManager(164): Displayed martin.android/.Overlay: +1s555ms
03-06 14:44:55.211: W/IInputConnectionWrapper(375): showStatusIcon on inactive InputConnection
03-06 14:44:55.211: W/InputManagerService(164): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41772888 (uid=10030 pid=375)
03-06 14:44:57.297: D/dalvikvm(164): GC_EXPLICIT freed 581K, 12% free 13695K/15495K, paused 12ms+6ms

первое сканирование:

03-06 14:45:30.778: I/ActivityManager(164): START {act=com.google.zxing.client.android.SCAN cat=[android.intent.category.DEFAULT] flg=0x4080000 pkg=com.google.zxing.client.android cmp=com.google.zxing.client.android/.CaptureActivity (has extras)} from pid 1582
03-06 14:45:30.903: D/dalvikvm(164): GC_FOR_ALLOC freed 118K, 12% free 13647K/15495K, paused 68ms
03-06 14:45:30.903: I/dalvikvm-heap(164): Grow heap (frag case) to 13.503MB for 129616-byte allocation
03-06 14:45:30.961: D/dalvikvm(164): GC_FOR_ALLOC freed 4K, 12% free 13770K/15623K, paused 57ms
03-06 14:45:30.977: I/ActivityManager(164): Start proc com.google.zxing.client.android for activity com.google.zxing.client.android/.CaptureActivity: pid=1605 uid=10055 gids={1006, 3003, 1015}
03-06 14:45:30.989: I/dalvikvm(1605): Turning on JNI app bug workarounds for target SDK version 7...
03-06 14:45:31.028: D/OpenGLRenderer(1582): Flushing caches (mode 1)
03-06 14:45:31.071: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): calling mSecCamera->stopPreview() and waiting
03-06 14:45:31.133: I/CameraHardwareSec(81): void android::CameraHardwareSec::stopPreviewInternal() : preview not running, doing nothing
03-06 14:45:31.133: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): return from wait
03-06 14:45:31.133: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): exiting
03-06 14:45:31.133: W/SecCamera(81): int android::SecCamera::stopPreview(): doing nothing because m_flag_camera_start is zero
03-06 14:45:31.133: W/SecCamera(81): int android::SecCamera::stopRecord(): doing nothing because m_flag_record_start is zero
03-06 14:45:31.133: I/SecCamera(81): DeinitCamera: m_cam_fd(28)
03-06 14:45:31.137: I/SecCamera(81): DeinitCamera: m_cam_fd2(29)
03-06 14:45:31.149: E/CameraHardwareSec(81): preview window is NULL!
03-06 14:45:31.149: I/CameraService(81): Destroying camera 0
03-06 14:45:31.149: I/CameraHardwareSec(81): int android::HAL_camera_device_close(hw_device_t*)
03-06 14:45:31.149: I/SecCamera(81): DeinitCamera : already deinitialized
03-06 14:45:31.153: W/AudioFlinger(81): session id 5 not found for pid 81
03-06 14:45:31.157: W/AudioFlinger(81): session id 6 not found for pid 81
03-06 14:45:31.164: D/OpenGLRenderer(1582): Flushing caches (mode 0)
03-06 14:45:31.231: V/PhoneStatusBar(238): setLightsOn(true)
03-06 14:45:31.246: I/CameraService(81): Opening camera 0
03-06 14:45:31.246: I/CameraHardwareSec(81): int android::HAL_camera_device_open(const hw_module_t*, const char*, hw_device_t**): open camera 0
03-06 14:45:31.246: E/SecCamera(81): initCamera: m_cam_fd(31), m_jpeg_fd(0)
03-06 14:45:31.246: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:45:31.250: E/SecCamera(81): initCamera: m_cam_fd2(32)
03-06 14:45:31.250: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:45:31.250: I/SecCamera(81): initCamera : initialized
03-06 14:45:31.250: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:45:31.250: I/CameraHardwareSec(81): int android::HAL_camera_device_open(const hw_module_t*, const char*, hw_device_t**): opened camera 0 (0x1461270)
03-06 14:45:31.254: I/AwesomePlayer(81): setDataSource_l('/system/media/audio/ui/camera_click.ogg')
03-06 14:45:31.258: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): starting
03-06 14:45:31.258: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): calling mSecCamera->stopPreview() and waiting
03-06 14:45:31.258: W/SecCamera(81): int android::SecCamera::stopPreview(): doing nothing because m_flag_camera_start is zero
03-06 14:45:31.262: I/AwesomePlayer(81): setDataSource_l('/system/media/audio/ui/VideoRecord.ogg')
03-06 14:45:31.282: I/CameraConfiguration(1605): Screen resolution: Point(800, 480)
03-06 14:45:31.282: I/CameraConfiguration(1605): Camera resolution: Point(720, 480)
03-06 14:45:31.286: I/CameraConfiguration(1605): Supported values: [on, off, auto, torch]
03-06 14:45:31.289: I/CameraConfiguration(1605): Settable value: off
03-06 14:45:31.289: I/CameraConfiguration(1605): Supported values: [auto, infinity, macro]
03-06 14:45:31.289: I/CameraConfiguration(1605): Settable value: auto
03-06 14:45:32.176: D/CameraHardwareSec(81): mPreviewHeap(fd(31), size(518400), width(720), height(480))
03-06 14:45:32.180: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): return from wait
03-06 14:45:32.262: D/d(1605): Calculated framing rect: Rect(100, 60 - 700, 420)
03-06 14:45:32.270: I/ActivityManager(164): Displayed com.google.zxing.client.android/.CaptureActivity: +1s307ms
03-06 14:45:32.457: D/dalvikvm(1605): GC_FOR_ALLOC freed 203K, 4% free 9191K/9479K, paused 37ms
03-06 14:45:32.461: I/dalvikvm-heap(1605): Grow heap (frag case) to 9.516MB for 518416-byte allocation
03-06 14:45:32.504: D/dalvikvm(1605): GC_CONCURRENT freed 4K, 3% free 9693K/9991K, paused 1ms+2ms
03-06 14:45:32.664: D/dalvikvm(1605): GC_FOR_ALLOC freed 738K, 10% free 9189K/10183K, paused 29ms
03-06 14:45:32.692: D/dalvikvm(1605): GC_CONCURRENT freed 0K, 5% free 9695K/10183K, paused 2ms+2ms
.
.
.
03-06 14:45:37.411: D/dalvikvm(1605): GC_FOR_ALLOC freed 733K, 10% free 9189K/10183K, paused 16ms
03-06 14:45:37.454: D/dalvikvm(1605): GC_CONCURRENT freed <1K, 5% free 9695K/10183K, paused 1ms+3ms
03-06 14:45:37.590: D/dalvikvm(1605): GC_FOR_ALLOC freed 733K, 10% free 9189K/10183K, paused 15ms
03-06 14:45:37.637: D/dalvikvm(1605): GC_CONCURRENT freed <1K, 5% free 9695K/10183K, paused 2ms+2ms
03-06 14:45:37.711: D/l(1605): Found barcode in 89 ms
03-06 14:45:37.739: D/dalvikvm(1605): GC_FOR_ALLOC freed 242K, 5% free 9729K/10183K, paused 26ms
03-06 14:45:37.739: I/dalvikvm-heap(1605): Grow heap (frag case) to 10.289MB for 777616-byte allocation
03-06 14:45:37.789: D/dalvikvm(1605): GC_CONCURRENT freed 0K, 5% free 10488K/10951K, paused 2ms+3ms
03-06 14:45:37.813: D/dalvikvm(1605): GC_FOR_ALLOC freed <1K, 5% free 10488K/10951K, paused 17ms
03-06 14:45:37.817: I/dalvikvm-heap(1605): Grow heap (frag case) to 11.030MB for 777616-byte allocation
03-06 14:45:37.848: D/dalvikvm(1605): GC_FOR_ALLOC freed 0K, 5% free 11248K/11719K, paused 23ms
03-06 14:45:37.856: D/v(1605): Got decode succeeded message
03-06 14:45:38.071: D/AudioHardware(81): AudioHardware pcm playback is exiting standby.
03-06 14:45:38.071: D/AudioHardware(81): openPcmOut_l() mPcmOpenCnt: 0
03-06 14:45:39.563: D/v(1605): Got return scan result message
03-06 14:45:39.719: D/dalvikvm(164): GC_FOR_ALLOC freed 46K, 12% free 13788K/15623K, paused 94ms
03-06 14:45:39.719: I/dalvikvm-heap(164): Grow heap (frag case) to 13.640MB for 129616-byte allocation
03-06 14:45:39.778: D/dalvikvm(164): GC_FOR_ALLOC freed 15K, 12% free 13899K/15751K, paused 59ms
03-06 14:45:39.840: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): calling mSecCamera->stopPreview() and waiting
03-06 14:45:39.911: I/CameraHardwareSec(81): void android::CameraHardwareSec::stopPreviewInternal() : preview not running, doing nothing
03-06 14:45:39.911: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): return from wait
03-06 14:45:39.911: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): exiting
03-06 14:45:39.911: W/SecCamera(81): int android::SecCamera::stopPreview(): doing nothing because m_flag_camera_start is zero
03-06 14:45:39.914: W/SecCamera(81): int android::SecCamera::stopRecord(): doing nothing because m_flag_record_start is zero
03-06 14:45:39.914: I/SecCamera(81): DeinitCamera: m_cam_fd(31)
03-06 14:45:39.926: I/SecCamera(81): DeinitCamera: m_cam_fd2(32)
03-06 14:45:39.946: E/CameraHardwareSec(81): preview window is NULL!
03-06 14:45:39.946: I/CameraService(81): Destroying camera 0
03-06 14:45:39.946: I/CameraHardwareSec(81): int android::HAL_camera_device_close(hw_device_t*)
03-06 14:45:39.946: I/SecCamera(81): DeinitCamera : already deinitialized
03-06 14:45:39.961: W/AudioFlinger(81): session id 8 not found for pid 81
03-06 14:45:39.965: W/AudioFlinger(81): session id 9 not found for pid 81
03-06 14:45:39.977: I/CameraService(81): Opening camera 0
03-06 14:45:39.977: I/CameraHardwareSec(81): int android::HAL_camera_device_open(const hw_module_t*, const char*, hw_device_t**): open camera 0
03-06 14:45:39.981: E/SecCamera(81): initCamera: m_cam_fd(31), m_jpeg_fd(0)
03-06 14:45:39.981: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:45:39.989: E/SecCamera(81): initCamera: m_cam_fd2(32)
03-06 14:45:39.989: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:45:39.989: I/SecCamera(81): initCamera : initialized
03-06 14:45:39.989: I/SecCamera(81): Name of input channel[0] is S5K4ECGX
03-06 14:45:39.989: I/CameraHardwareSec(81): int android::HAL_camera_device_open(const hw_module_t*, const char*, hw_device_t**): opened camera 0 (0x144c118)
03-06 14:45:39.989: I/AwesomePlayer(81): setDataSource_l('/system/media/audio/ui/camera_click.ogg')
03-06 14:45:39.993: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): starting
03-06 14:45:39.993: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): calling mSecCamera->stopPreview() and waiting
03-06 14:45:39.993: W/SecCamera(81): int android::SecCamera::stopPreview(): doing nothing because m_flag_camera_start is zero
03-06 14:45:40.000: I/AwesomePlayer(81): setDataSource_l('/system/media/audio/ui/VideoRecord.ogg')
03-06 14:45:40.860: D/CameraHardwareSec(81): mPreviewHeap(fd(31), size(518400), width(720), height(480))
03-06 14:45:40.864: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): return from wait
03-06 14:45:41.258: I/ActivityManager(164): No longer want com.google.android.deskclock (pid 1415): hidden #16
03-06 14:45:41.516: D/AudioHardware(81): AudioHardware pcm playback is going to standby.
03-06 14:45:41.516: D/AudioHardware(81): closePcmOut_l() mPcmOpenCnt: 1

второе сканирование (сканирование ошибок):

03-06 14:35:09.245: I/ActivityManager(152): START {act=com.google.zxing.client.android.SCAN cat=[android.intent.category.DEFAULT] flg=0x4080000 pkg=com.google.zxing.client.android cmp=com.google.zxing.client.android/.CaptureActivity (has extras)} from pid 1871
03-06 14:35:09.382: D/dalvikvm(152): GC_FOR_ALLOC freed 381K, 13% free 13774K/15687K, paused 105ms
03-06 14:35:09.456: D/OpenGLRenderer(1871): Flushing caches (mode 1)
03-06 14:35:09.491: V/PhoneStatusBar(226): setLightsOn(true)
03-06 14:35:09.514: W/CameraService(81): CameraService::connect X (pid 1896) rejected (existing client).
03-06 14:35:09.534: W/CaptureActivity(1896): Unexpected error initializing camera
03-06 14:35:09.534: W/CaptureActivity(1896): java.lang.RuntimeException: Fail to connect to camera service
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.hardware.Camera.native_setup(Native Method)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.hardware.Camera.<init>(Camera.java:302)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.hardware.Camera.open(Camera.java:279)
03-06 14:35:09.534: W/CaptureActivity(1896):    at com.google.zxing.client.android.b.d.a(Unknown Source)
03-06 14:35:09.534: W/CaptureActivity(1896):    at com.google.zxing.client.android.CaptureActivity.a(Unknown Source)
03-06 14:35:09.534: W/CaptureActivity(1896):    at com.google.zxing.client.android.CaptureActivity.surfaceCreated(Unknown Source)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.view.SurfaceView.updateWindow(SurfaceView.java:533)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.view.SurfaceView.access$000(SurfaceView.java:81)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:169)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1617)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.os.Looper.loop(Looper.java:137)
03-06 14:35:09.534: W/CaptureActivity(1896):    at android.app.ActivityThread.main(ActivityThread.java:4424)
03-06 14:35:09.534: W/CaptureActivity(1896):    at java.lang.reflect.Method.invokeNative(Native Method)
03-06 14:35:09.534: W/CaptureActivity(1896):    at java.lang.reflect.Method.invoke(Method.java:511)
03-06 14:35:09.534: W/CaptureActivity(1896):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-06 14:35:09.534: W/CaptureActivity(1896):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-06 14:35:09.534: W/CaptureActivity(1896):    at dalvik.system.NativeStart.main(Native Method)
03-06 14:35:09.710: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): calling mSecCamera->stopPreview() and waiting
03-06 14:35:09.721: I/ActivityManager(152): Displayed com.google.zxing.client.android/.CaptureActivity: +334ms
03-06 14:35:09.776: I/CameraHardwareSec(81): void android::CameraHardwareSec::stopPreviewInternal() : preview not running, doing nothing
03-06 14:35:09.776: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): return from wait
03-06 14:35:09.776: I/CameraHardwareSec(81): int android::CameraHardwareSec::previewThreadWrapper(): exiting
03-06 14:35:09.776: W/SecCamera(81): int android::SecCamera::stopPreview(): doing nothing because m_flag_camera_start is zero
03-06 14:35:09.776: W/SecCamera(81): int android::SecCamera::stopRecord(): doing nothing because m_flag_record_start is zero
03-06 14:35:09.776: I/SecCamera(81): DeinitCamera: m_cam_fd(28)
03-06 14:35:09.780: I/SecCamera(81): DeinitCamera: m_cam_fd2(29)
03-06 14:35:09.788: E/CameraHardwareSec(81): preview window is NULL!
03-06 14:35:09.788: I/CameraService(81): Destroying camera 0
03-06 14:35:09.788: I/CameraHardwareSec(81): int android::HAL_camera_device_close(hw_device_t*)
03-06 14:35:09.788: I/SecCamera(81): DeinitCamera : already deinitialized
03-06 14:35:09.792: W/AudioFlinger(81): session id 22 not found for pid 81
03-06 14:35:09.796: W/AudioFlinger(81): session id 23 not found for pid 81
03-06 14:35:09.796: D/OpenGLRenderer(1871): Flushing caches (mode 0)

Ответы [ 4 ]

5 голосов
/ 24 июля 2012

Вы добавили разрешение

<uses-permission android:name="android.permission.CAMERA"/>

к вашему манифесту?

0 голосов
/ 03 марта 2015

Благодаря @Rob я понял, что не закрывал драйвер камеры, поэтому просто добавьте приведенный ниже код в onPause

    cameraManager.closeDriver();       
0 голосов
/ 14 февраля 2014

Я знаю, что это давным-давно, но это потому, что запущен существующий клиент камеры.Я думаю, что вы не освобождаете камеру между вызовами.

0 голосов
/ 03 марта 2012

Для интеграции существует намерение перенаправить наше приложение в приложение zxing и получить результат.Посмотрите на мой ответ здесь

...