2014-04-21 247 views
2

我知道這個問題已被問了很多次,但沒有一個答案解決了我的問題。在我的應用程序中,我使用了在沒有預覽的情況下拍攝照片的服務。我的應用在三星Galaxy S2,三星Grand等大多數Android手機上運行良好,但是當我在Sony Experia M 4.1.2和Samsung Galaxy Core Duos 4.1.2上測試時,它會在myCamera.takePicture中引發運行時異常。Camera.takePicture throws RunTimeException

我按照計算器上的許多鏈接,但無法找到解決辦法:

這是我的代碼:

@Override 
public void onCreate() { 
    super.onCreate(); 
    Camera cameraInstance = null; 
    try{ 
     cameraInstance= Camera.open(); 
     if(cameraInstance != null){ 
      cameraInstance.lock(); 
      SurfaceView dummy = new SurfaceView(this); 
      cameraInstance.setPreviewDisplay(dummy.getHolder()); 
      cameraInstance.startPreview(); 
      cameraInstance.takePicture(null, null, jpeg); 
     }else{ 
      Log.e("MyCamera", "Could not open camera"); 
     } 
    }catch(Throwable t){ 
     Log.e("MyCamera", t.getMessage()); 

      if(cameraInstance!=null){ 
       cameraInstance.stopPreview(); 
       cameraInstance.unlock(); 
       cameraInstance.release(); 
       cameraInstance = null; 
      } 
    }finally{ 
     stopSelf(); 
    } 
} 

PictureCallback jpeg = new PictureCallback() { 
    @Override 
    public void onPictureTaken(byte[] data, Camera camera) { 
     FileOutputStream fos = null; 
     try { 
      camera.stopPreview(); 
      camera.unlock(); 
      camera.release(); 
      camera = null; 

      File file = AndroidAppUtil.getClientFile(String.valueOf(new Date().getTime())); 
      fos = new FileOutputStream(file); 

      BitmapFactory.Options options = new BitmapFactory.Options(); 
      options.inPurgeable = true; 
      options.inTempStorage = new byte[32 * 1024]; 

      Bitmap bMap = BitmapFactory.decodeByteArray(data, 0, data.length, options); 
      Matrix matrix = new Matrix(); 
      matrix.postRotate(90); 

      Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(), bMap.getHeight(), matrix, false); 
      bMapRotate.compress(Bitmap.CompressFormat.JPEG, 95, fos); 
      bMap.recycle(); 
      bMapRotate.recycle(); 
     } catch (Throwable t) { 
      System.gc(); 
     } finally { 
      if (fos != null){ 
       try { 
        fos.close(); 
       } catch (IOException e) { 
       } 
      } 
     } 
    } 
}; 

堆棧跟蹤:

04-21 12:38:28.321: D/QualcommCamera(285): Qint android::preview_enabled(camera_device*): E 
04-21 12:38:28.321: D/QCameraHWI(285): int android::QCameraHardwareInterface::previewEnabled(): mCameraState = 1 
04-21 12:38:28.321: D/QCameraHWI(285): setPreviewWindow: E mPreviewState = 0, mStreamDisplay = 0x40a8e828 
04-21 12:38:28.321: D/QCameraHWI(285): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*):Received Setting NULL preview window 
04-21 12:38:28.321: D/QCameraHWI(285): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*): mPreviewWindow = 0x0x0, mStreamDisplay = 0x0x40a8e828 
04-21 12:38:28.321: E/QCameraHWI_Preview(285): setPreviewWindow: E 
04-21 12:38:28.321: W/QCameraHWI_Preview(285): Setting NULL preview window 
04-21 12:38:28.321: D/QCameraHWI(285): setPreviewWindow : X, mPreviewState = 0 
04-21 12:38:28.321: D/QualcommCamera(285): Qint android::start_preview(camera_device*): E 
04-21 12:38:28.331: D/QCameraHWI(285): android::status_t android::QCameraHardwareInterface::startPreview(): mPreviewState =0 
04-21 12:38:28.331: D/QCameraHWI(285): android::status_t android::QCameraHardwareInterface::startPreview(): HAL::startPreview begin 
04-21 12:38:28.331: D/QCameraHWI(285): android::status_t android::QCameraHardwareInterface::startPreview(): received startPreview, but preview window = null 
04-21 12:38:28.331: D/QualcommCamera(285): Qint android::start_preview(camera_device*): X 
04-21 12:38:30.373: D/QualcommCamera(285): Qvoid android::disable_msg_type(camera_device*, int32_t): E 
04-21 12:38:30.373: D/QCameraHWI(285): disableMsgType: X, msgType =0x400, mMsgEnabled=0xd 
04-21 12:38:30.373: D/QCameraHWI(285): enableMsgType: X, msgType =0x100, mMsgEnabled=0x10d 
04-21 12:38:30.373: D/QualcommCamera(285): Qchar* android::get_parameters(camera_device*): E 
04-21 12:38:30.373: D/QualcommCamera(285): Qchar* android::get_parameters(camera_device*): X[1] 
04-21 12:38:30.373: D/QualcommCamera(285): Qvoid android::put_parameters(camera_device*, char*): E 
04-21 12:38:30.384: D/QualcommCamera(285): Qint android::take_picture(camera_device*): E 
04-21 12:38:30.384: D/QCameraHWI_Still(285): virtual void android::QCameraStream_Snapshot::resetSnapshotCounters(): Number of images to be captured: 1 
04-21 12:38:30.384: E/QCameraHWI_Still(285): virtual void android::QCameraStream_Snapshot::InitHdrInfoForSnapshot(bool, int, int*): number_frames=1 
04-21 12:38:30.914: W/SignalStrength(629): getLTELevel - rsrp:2147483647 snr:2147483647 rsrpIconLevel:-1 snrIconLevel:-1 
04-21 12:38:30.914: W/SignalStrength(823): getLTELevel - rsrp:2147483647 snr:2147483647 rsrpIconLevel:-1 snrIconLevel:-1 
04-21 12:38:30.914: W/SignalStrength(823): getLTELevel - rssi:99 rssiIconLevel:0 
04-21 12:38:30.914: W/SignalStrength(823): getTdScdmaLevel = 0 
04-21 12:38:30.924: W/SignalStrength(823): getGsmLevel=4 
04-21 12:38:30.924: W/SignalStrength(823): getLevel=4 
04-21 12:38:30.924: W/SignalStrength(823): getLTELevel - rsrp:2147483647 snr:2147483647 rsrpIconLevel:-1 snrIconLevel:-1 
04-21 12:38:30.924: W/SignalStrength(629): getLTELevel - rssi:99 rssiIconLevel:0 
04-21 12:38:30.924: W/SignalStrength(823): getLTELevel - rssi:99 rssiIconLevel:0 
04-21 12:38:30.924: W/SignalStrength(629): getTdScdmaLevel = 0 
04-21 12:38:30.924: W/SignalStrength(823): getTdScdmaLevel = 0 
04-21 12:38:30.924: W/SignalStrength(629): getGsmLevel=4 
04-21 12:38:30.924: W/SignalStrength(629): getLevel=4 
04-21 12:38:30.924: W/SignalStrength(823): getGsmLevel=4 
04-21 12:38:30.924: D/StatusBar.NetworkController(823): onSignalStrengthsChanged signalStrength=SignalStrength: 14 0 -120 -160 -120 -1 -1 99 2147483647 2147483647 2147483647 2147483647 2147483647 gsm|lte level=4 
04-21 12:38:30.934: W/SignalStrength(823): getLevel=4 
04-21 12:38:30.934: W/SignalStrength(823): getLTELevel - rsrp:2147483647 snr:2147483647 rsrpIconLevel:-1 snrIconLevel:-1 
04-21 12:38:30.934: W/SignalStrength(823): getLTELevel - rssi:99 rssiIconLevel:0 
04-21 12:38:30.934: W/SignalStrength(823): getTdScdmaLevel = 0 
04-21 12:38:30.934: W/SignalStrength(823): getGsmLevel=4 
04-21 12:38:30.934: W/SignalStrength(823): getLevel=4 
04-21 12:38:30.934: D/StatusBar.NetworkController(823): refreshViews connected={ data } level=4 combinedSignalIconId=0x7f0200a7/com.android.systemui:drawable/stat_sys_signal_4_fully combinedActivityIconId=0x7f0200a8 mobileLabel=airtel wifiLabel= emergencyOnly=false combinedLabel=airtel mAirplaneMode=false mDataActivity=0 mPhoneSignalIconId=0x7f0200a7 mDataDirectionIconId=0x7f020084 mDataSignalIconId=0x7f0200a7 mDataTypeIconId=0x7f020076 mNoSimIconId=0x0 mWifiIconId=0x0 mBluetoothTetherIconId=0x108076a 
04-21 12:38:40.144: D/PowerManagerService(629): [PMS] updateLightsLocked: newState = 1/ forceState = 0 
04-21 12:38:40.144: D/PowerManagerService(629): [PMS] nominalCurrentValue=145 brightness=20 steps=77 
04-21 12:38:47.161: D/PowerManagerService(629): [PMS] updateLightsLocked: newState = 0/ forceState = 0 
04-21 12:38:47.161: D/PowerManagerService(629): [PMS] nominalCurrentValue=20 brightness=0 steps=12 
04-21 12:38:47.342: I/AlarmManager(629): trigger Alarm{432ca750 type 0 com.appbell.pml.user.ui} [type=0 when=(2014-04-21 12:38:47) repeatInt=30000 PendingIntent{42d95b90: PendingIntentRecord{432cca18 com.appbell.pml.user.ui startService}}] 
04-21 12:38:47.662: I/VibratorService(629): service.runit.start: 0 
04-21 12:38:47.682: I/NotificationService(629): [FXN.ASD]nms:mInCall = false/mScreenOn = false/mLedNotification = null 
04-21 12:38:47.682: I/NotificationService(629): [FXN.ASD]nms:turn off LED 
04-21 12:38:47.692: D/AudioHardwareALSA(285): setParameters() screen_state=off 
04-21 12:38:47.692: V/AudioHardwareALSA(285): __start set mic 
04-21 12:38:47.692: V/AudioHardwareALSA(285): __start set hac parameters 
04-21 12:38:47.762: D/AccelerometerListener(888): enable(false) 
04-21 12:38:47.772: D/NfcService(904): NFC-C OFF, disconnect 
04-21 12:38:47.772: D/NFC_LIST(904): Allocated node: 0x5dd92420 (0x60833c5c) 
04-21 12:38:47.782: I/PhoneLedService(888): mPhoneLedReceiver onReceive(): android.intent.action.SCREEN_OFF 
04-21 12:38:47.782: D/NFCJNI(904): ****** Stop NFC Discovery ****** 
04-21 12:38:47.802: D/NFCJNI(904): phLibNfc_Mgt_ConfigureDiscovery(-----, CE-0-493e0) returned 0x0000000d 
04-21 12:38:47.822: D/NFCJNI(904): Callback: nfc_jni_discover_callback() - status=0x0000[NFCSTATUS_SUCCESS] 
04-21 12:38:47.822: D/NFC_LIST(904): Deallocating node: 0x5dd92420 (0x60833c5c) 
04-21 12:38:47.822: V/SuperStamina-XssmReminder(629): onScreenOn: false 
04-21 12:38:47.822: V/SuperStamina-XssmReminder(629): ... state: xssmOn=false plugged=true off=0 
04-21 12:38:47.872: D/YouTube MDX(6902): Recieved intent android.intent.action.SCREEN_OFF 
04-21 12:38:48.092: W/ActivityManager(629): Activity pause timeout for ActivityRecord{42925e38 com.appbell.pml.user.ui/com.appbell.and.common.util.CustomAlertDialog} 
04-21 12:38:49.274: I/AlarmManager(629): trigger Alarm{434208d8 type 2 com.google.android.gms} [type=2 when=(2014-04-21 12:38:49) repeatInt=0 PendingIntent{43321f48: PendingIntentRecord{42b756b0 com.google.android.gms broadcastIntent}}] 
04-21 12:38:51.686: I/BatteryService(629): start UEvent update, event = {SUBSYSTEM=power_supply, DEVPATH=/devices/platform/msm_ssbi.0/pm8038-core/pm8921-charger/power_supply/battery, POWER_SUPPLY_HEALTH=Good, POWER_SUPPLY_STATUS=Charging, POWER_SUPPLY_TECHNOLOGY=Li-ion, POWER_SUPPLY_ENERGY_FULL=1743000, POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3200000, POWER_SUPPLY_TEMP=374, POWER_SUPPLY_PRESENT=1, POWER_SUPPLY_NAME=battery, POWER_SUPPLY_CHARGE_NOW=-33712, POWER_SUPPLY_CURRENT_MAX=3381843, POWER_SUPPLY_CAPACITY=87, POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4200000, SEQNUM=26702, POWER_SUPPLY_CURRENT_NOW=-457700, POWER_SUPPLY_VOLTAGE_NOW=4092957, ACTION=change, POWER_SUPPLY_CHARGE_TYPE=Fast} 
04-21 12:38:52.577: I/AlarmManager(629): trigger Alarm{43611128 type 2 android} [type=2 when=(2014-04-21 12:38:52) repeatInt=0 PendingIntent{43756cc8: PendingIntentRecord{43616a60 android broadcastIntent}}] 
04-21 12:38:52.597: W/ActivityManager(629): Sleep timeout! Sleeping now. 
04-21 12:38:52.968: D/-heap(4337): GC_CONCURRENT freed 2869K, 46% free 9291K/17027K, paused 16ms+8ms, total 150ms 
04-21 12:38:55.701: I/BatteryService(629): start UEvent update, event = {SUBSYSTEM=power_supply, DEVPATH=/devices/platform/msm_ssbi.0/pm8038-core/pm8921-charger/power_supply/battery, POWER_SUPPLY_HEALTH=Good, POWER_SUPPLY_STATUS=Charging, POWER_SUPPLY_TECHNOLOGY=Li-ion, POWER_SUPPLY_ENERGY_FULL=1743000, POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3200000, POWER_SUPPLY_TEMP=374, POWER_SUPPLY_PRESENT=1, POWER_SUPPLY_NAME=battery, POWER_SUPPLY_CHARGE_NOW=-34218, POWER_SUPPLY_CURRENT_MAX=3381843, POWER_SUPPLY_CAPACITY=88, POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4200000, SEQNUM=26703, POWER_SUPPLY_CURRENT_NOW=-460600, POWER_SUPPLY_VOLTAGE_NOW=4094421, ACTION=change, POWER_SUPPLY_CHARGE_TYPE=Fast} 
04-21 12:38:55.731: V/SuperStamina-XssmReminder(629): onBatteryChanged: plugged=true 
04-21 12:38:55.731: V/SuperStamina-PowerSaveReminder(629): onBatteryChanged: level=88 plugged=true 
04-21 12:38:55.731: V/SuperStamina-PowerSaveReminder(629): ... state: enabled=false mPlugged=true mUnpluggedTime=0 mUnpluggedLevel=0 
04-21 12:38:58.103: W/ActivityManager(629): Activity stop timeout for ActivityRecord{42a7d8e0 com.appbell.pml.user.ui/com.appbell.and.pml.ca.app.ui.DashboardActivity} 
04-21 12:38:58.103: W/ActivityManager(629): Activity stop timeout for ActivityRecord{42925e38 com.appbell.pml.user.ui/com.appbell.and.common.util.CustomAlertDialog} 
04-21 12:39:09.806: I/AlarmManager(629): trigger Alarm{429b7c28 type 2 com.google.android.gms} [type=2 when=(2014-04-21 12:39:09) repeatInt=0 PendingIntent{429edb18: PendingIntentRecord{429d5300 com.google.android.gms broadcastIntent}}] 
04-21 12:39:09.826: D/StateMachine(629): handleMessage: E msg.what=131084 
04-21 12:39:09.826: D/StateMachine(629): processMsg: DriverUnloadedState 
04-21 12:39:09.826: D/WifiStateMachine(629): DriverUnloadedState{ what=131084 when=-2ms } 
04-21 12:39:09.826: D/StateMachine(629): processMsg: DefaultState 
04-21 12:39:09.826: D/WifiStateMachine(629): DefaultState{ what=131084 when=-4ms } 
04-21 12:39:09.836: D/StateMachine(629): handleMessage: X 
04-21 12:39:09.836: D/StateMachine(629): handleMessage: E msg.what=131074 
04-21 12:39:09.836: D/StateMachine(629): processMsg: DriverUnloadedState 
04-21 12:39:09.836: D/WifiStateMachine(629): DriverUnloadedState{ what=131074 when=-9ms arg1=1 } 
04-21 12:39:09.836: D/StateMachine(629): processMsg: DefaultState 
04-21 12:39:09.836: D/WifiStateMachine(629): DefaultState{ what=131074 when=-11ms arg1=1 } 
04-21 12:39:09.836: D/StateMachine(629): handleMessage: X 
04-21 12:39:09.876: D/StateMachine(629): handleMessage: E msg.what=131084 
04-21 12:39:09.876: D/StateMachine(629): processMsg: DriverUnloadedState 
04-21 12:39:09.876: D/WifiStateMachine(629): DriverUnloadedState{ what=131084 when=-2ms } 
04-21 12:39:09.876: D/StateMachine(629): processMsg: DefaultState 
04-21 12:39:09.876: D/WifiStateMachine(629): DefaultState{ what=131084 when=-5ms } 
04-21 12:39:09.876: D/StateMachine(629): handleMessage: X 
04-21 12:39:09.876: D/StateMachine(629): handleMessage: E msg.what=131074 
04-21 12:39:09.886: D/StateMachine(629): processMsg: DriverUnloadedState 
04-21 12:39:09.886: D/WifiStateMachine(629): DriverUnloadedState{ what=131074 when=-10ms arg1=1 } 
04-21 12:39:09.886: D/StateMachine(629): processMsg: DefaultState 
04-21 12:39:09.886: D/WifiStateMachine(629): DefaultState{ what=131074 when=-13ms arg1=1 } 
04-21 12:39:09.886: D/StateMachine(629): handleMessage: X 
04-21 12:39:14.150: E/MyCamera(7591): takePicture failed 
04-21 12:39:15.081: D/QualcommCamera(285): Qvoid android::disable_msg_type(camera_device*, int32_t): E 
04-21 12:39:15.081: D/QCameraHWI(285): disableMsgType: X, msgType =0x400, mMsgEnabled=0x10d 
04-21 12:39:15.081: D/QualcommCamera(285): Qvoid android::disable_msg_type(camera_device*, int32_t): E 
04-21 12:39:15.081: D/QCameraHWI(285): disableMsgType: X, msgType =0x10, mMsgEnabled=0x10d 
04-21 12:39:15.081: D/QualcommCamera(285): Qvoid android::disable_msg_type(camera_device*, int32_t): E 
04-21 12:39:15.081: D/QCameraHWI(285): disableMsgType: X, msgType =0x3c2, mMsgEnabled=0xd 
04-21 12:39:15.081: D/QualcommCamera(285): Qvoid android::stop_preview(camera_device*): E 
04-21 12:39:15.081: D/QCameraHWI(285): void android::QCameraHardwareInterface::stopPreview(): stopPreview: E 
04-21 12:39:15.081: E/mm-libcamera2(285): PROFILE HAL: stopPreview(): E: 1398064155.095584038 
04-21 12:39:15.091: D/QCameraHWI(285): stopPreview: X, mPreviewState = 0 
04-21 12:39:15.462: D/QualcommCamera(285): Qint android::recording_enabled(camera_device*): E 
04-21 12:39:15.672: W/CameraService(285): attempt to use a locked camera from a different process (old pid 0, new pid 7591) 
04-21 12:39:15.672: W/CameraService(285): attempt to use a locked camera from a different process (old pid 0, new pid 7591) 
04-21 12:39:15.672: W/CameraService(285): different client - don't disconnect 
04-21 12:39:17.344: I/AlarmManager(629): trigger Alarm{432ca750 type 0 com.appbell.pml.user.ui} [type=0 when=(2014-04-21 12:39:17) repeatInt=30000 PendingIntent{42d95b90: PendingIntentRecord{432cca18 com.appbell.pml.user.ui startService}}] 
04-21 12:39:17.394: W/ActivityManager(629): Timeout executing service: ServiceRecord{436caf28 com.appbell.pml.user.ui/com.appbell.and.pml.ca.app.service.LocationCaptureMonitorService} 
04-21 12:39:18.154: I/AlarmManager(629): trigger Alarm{42a95700 type 2 com.google.android.gms} [type=2 when=(2014-04-21 12:39:17) repeatInt=0 PendingIntent{42af8fc8: PendingIntentRecord{42b1ca58 com.google.android.gms broadcastIntent}}] 
04-21 12:39:18.154: I/AlarmManager(629): trigger Alarm{43439cc8 type 2 com.google.android.gsf} [type=2 when=(1970-01-01 05:30:00) repeatInt=0 PendingIntent{42aeabc8: PendingIntentRecord{43133218 com.google.android.gsf broadcastIntent}}] 
04-21 12:39:18.695: D/-heap(629): GC_CONCURRENT freed 2742K, 36% free 17516K/27143K, paused 14ms+11ms, total 128ms 
04-21 12:39:18.705: D/dalvikvm(629): WAIT_FOR_CONCURRENT_GC blocked 89ms 
04-21 12:39:18.905: D/dalvikvm(629): WAIT_FOR_CONCURRENT_GC blocked 0ms 
04-21 12:39:19.045: D/-heap(629): GC_EXPLICIT freed 875K, 35% free 17700K/27143K, paused 6ms+11ms, total 134ms 
04-21 12:39:19.606: E/ActivityManager(629): ANR in com.appbell.pml.user.ui 
04-21 12:39:19.606: E/ActivityManager(629): Reason: Executing service com.appbell.pml.user.ui/com.appbell.and.pml.ca.app.service.LocationCaptureMonitorService 
04-21 12:39:19.606: E/ActivityManager(629): Load: 2.39/9.61/8.39 
04-21 12:39:19.606: E/ActivityManager(629): CPU usage from 12396ms to 2577ms ago: 
04-21 12:39:19.606: E/ActivityManager(629): 0.9% 629/system_server: 0.3% user + 0.6% kernel/faults: 43 minor 
04-21 12:39:19.606: E/ActivityManager(629): 0.1% 372/adbd: 0% user + 0.1% kernel 
04-21 12:39:19.606: E/ActivityManager(629): 0.2% 3160/mpdecision: 0% user + 0.2% kernel 
04-21 12:39:19.606: E/ActivityManager(629): 0.2% 4337/com.google.process.location: 0.1% user + 0.1% kernel/faults: 2 minor 
04-21 12:39:19.606: E/ActivityManager(629): 0% 281/rild: 0% user + 0% kernel/faults: 2 minor 
04-21 12:39:19.606: E/ActivityManager(629): 0.1% 4807/com.sonymobile.playanywhere: 0% user + 0.1% kernel 
04-21 12:39:19.606: E/ActivityManager(629): 0% 5144/kworker/0:0: 0% user + 0% kernel 
04-21 12:39:19.606: E/ActivityManager(629): 0% 7185/logcat: 0% user + 0% kernel 
04-21 12:39:19.606: E/ActivityManager(629): 1.6% TOTAL: 0.5% user + 1.1% kernel 
04-21 12:39:19.606: E/ActivityManager(629): CPU usage from 1653ms to 2180ms later: 
04-21 12:39:19.606: E/ActivityManager(629): 3.7% 629/system_server: 0% user + 3.7% kernel 
04-21 12:39:19.606: E/ActivityManager(629):  5.6% 683/ActivityManager: 0% user + 5.6% kernel 
04-21 12:39:19.606: E/ActivityManager(629): 2.5% TOTAL: 0% user + 2.5% kernel 
04-21 12:39:19.616: D/ActivityManager(629): reading /data/anr/traces_com.appbell.pml.user.ui.txt 
04-21 12:39:20.687: D/QualcommCamera(285): Qvoid android::disable_msg_type(camera_device*, int32_t): E 
04-21 12:39:20.687: D/QCameraHWI(285): disableMsgType: X, msgType =0xffff, mMsgEnabled=0x0 
04-21 12:39:20.687: D/QualcommCamera(285): Qvoid android::stop_preview(camera_device*): E 
04-21 12:39:20.687: D/QCameraHWI(285): void android::QCameraHardwareInterface::stopPreview(): stopPreview: E 
04-21 12:39:20.687: E/mm-libcamera2(285): PROFILE HAL: stopPreview(): E: 1398064160.698422433 
04-21 12:39:20.687: D/QCameraHWI(285): stopPreview: X, mPreviewState = 0 
04-21 12:39:20.687: D/QualcommCamera(285): Qint android::cancel_picture(camera_device*): E 
04-21 12:39:20.687: D/QCameraHWI(285): cancelPicture: E 
04-21 12:39:20.687: D/QCameraHWI(285): cancelPicture: X 
04-21 12:39:20.687: D/QualcommCamera(285): Qvoid android::release(camera_device*): E 
04-21 12:39:20.687: D/QCameraHWI(285): release: E 
04-21 12:39:20.687: D/QCameraHWI(285): release: X 
04-21 12:39:20.687: D/QualcommCamera(285): Qint android::close_camera_device(hw_device_t*): device =0x4224edd8 E 
04-21 12:39:20.687: D/QCameraHWI(285): ~QCameraHardwareInterface: E 
04-21 12:39:20.687: E/QCameraHWI_Preview(285): virtual void android::QCameraStream_preview::release() : BEGIN 
04-21 12:39:20.687: E/QCameraHWI_Preview(285): Debug : virtual void android::QCameraStream_preview::release() : De init Channel 
04-21 12:39:20.687: E/mm-libcamera2(285): mm_camera_ch_util_reg_buf_cb: Trying to register 
04-21 12:39:20.687: E/mm-libcamera2(285): mm_camera_ch_util_reg_buf_cb: Done register 
04-21 12:39:20.687: E/QCameraHWI_Preview(285): virtual void android::QCameraStream_preview::release(): END 
04-21 12:39:20.687: E/mm-libcamera2(285): mm_camera_ch_util_reg_buf_cb: Trying to register 
04-21 12:39:20.687: E/mm-libcamera2(285): mm_camera_ch_util_reg_buf_cb: Done register 
04-21 12:39:20.687: V/QCameraHWI_Still(285): virtual void android::QCameraStream_Snapshot::release(): E 
04-21 12:39:20.687: V/QCameraHWI_Still(285): virtual void android::QCameraStream_Snapshot::release(): X 
04-21 12:39:20.697: V/QCameraHWI_Still(285): virtual android::QCameraStream_Snapshot::~QCameraStream_Snapshot(): E 
04-21 12:39:20.697: I/mm-still-omx(285): omxJpegClose: 
04-21 12:39:20.697: V/QCameraHWI_Still(285): virtual android::QCameraStream_Snapshot::~QCameraStream_Snapshot(): X 
04-21 12:39:20.697: E/mm-camera(300): config_shutdown_pp Camera not in streaming mode. Returning. 
04-21 12:39:20.697: E/mm-camera(300): mctl_release: set_params (SENSOR_SET_STOP_STREAM) 
04-21 12:39:20.697: E/mm-camera(300): vfe_ops_deinit: E 
04-21 12:39:20.707: D/QCameraHWI(285): ~QCameraHardwareInterface: X 
04-21 12:39:20.707: D/QualcommCamera(285): Qint android::close_camera_device(hw_device_t*): X : camera_count =0 
+1

你能提供運行時異常堆棧跟蹤請。 –

+0

我已添加stacktrace。 –

回答

2

最後我通過添加表面紋理和setPreviewTexture解決問題....

注:
在4.0以下使用虛擬SurfaceView版本。
在版本> = 4.0中使用SurfaceTexture(和setSurfaceTexture())代替SurfaceView。

https://stackoverflow.com/a/10248768/1713415