本文介绍了Camera.takePicture抛出的RuntimeException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我知道这个问题已经被问过很多次,但没有一个答案解决了我的问题。在我的应用程序,我已经使用的服务这需要照片时不preVIEW在后台。我的应用程序工作正常大多数的Andr​​oid手机类似三星Galaxy S2,三星大的,但是当我在索尼Experia还中号4.1.2和三星Galaxy核心二重奏4.1.2测试,它在myCamera.takePicture抛出运行时异常。

我按照计算器上的许多链接,但无法找到解决办法:





这是我的code:

  @覆盖
公共无效的onCreate(){
    super.onCreate();
    相机cameraInstance = NULL;
    尝试{
        cameraInstance = Camera.open();
        如果(cameraInstance!= NULL){
            cameraInstance.lock();
            SurfaceView哑=新SurfaceView(本);
            cameraInstance.set previewDisplay(dummy.getHolder());
            cameraInstance.start preVIEW();
            cameraInstance.takePicture(NULL,NULL,JPEG);
        }其他{
            Log.e(MyCamera,无法打开相机);
        }
    }赶上(的Throwable t)的{
        Log.e(MyCamera,t.getMessage());            如果(cameraInstance!= NULL){
                cameraInstance.stop preVIEW();
                cameraInstance.unlock();
                cameraInstance.release();
                cameraInstance = NULL;
            }
    }最后{
        stopSelf();
    }
}PictureCallback JPEG =新PictureCallback(){
    @覆盖
    公共无效onPictureTaken(字节[]数据,相机摄像头){
        FOS的FileOutputStream = NULL;
        尝试{
            camera.stop preVIEW();
            camera.unlock();
            camera.release();
            摄像头= NULL;            文件fil​​e = AndroidAppUtil.getClientFile(将String.valueOf(新的Date()的getTime()));
            FOS =新的FileOutputStream(文件);            BitmapFactory.Options选项=新BitmapFactory.Options();
            options.inPurgeable = TRUE;
            options.inTempStorage =新的字节[32 * 1024];            位图BMAP = BitmapFactory.de codeByteArray的(数据,0,data.length,期权);
            字模=新的Matrix();
            matrix.postRotate(90);            位图bMapRotate = Bitmap.createBitmap(BMAP,0,0,bMap.getWidth(),bMap.getHeight(),矩阵,假);
            bMapRotate.com preSS(Bitmap.Com pressFormat.JPEG,95,FOS);
            bMap.recycle();
            bMapRotate.recycle();
        }赶上(的Throwable t)的{
            System.gc()的;
        } {最后
            如果(FOS!= NULL){
                尝试{
                    fos.close();
                }赶上(IOException异常五){
                }
            }
        }
    }
};

堆栈跟踪:

  12月4日至21日:38:28.321:D / QualcommCamera(285):Qint机器人:: preview_enabled(camera_device *):电子
12月4日至21日:38:28.321:D / QCameraHWI(285):INT机器人:: QCameraHardwareInterface :: previewEnabled():mCameraState = 1
12月4日至21日:38:28.321:D / QCameraHWI(285):集previewWindow:电子米previewState = 0,mStreamDisplay = 0x40a8e828
12月4日至21日:38:28.321:D / QCameraHWI(285):安卓:: status_t机器人:: QCameraHardwareInterface ::集previewWindow(preview_stream_ops_t *):接收的设置NULL preVIEW窗口
12月4日至21日:38:28.321:D / QCameraHWI(285):安卓:: status_t机器人:: QCameraHardwareInterface ::集previewWindow(preview_stream_ops_t *):M previewWindow = 0x0x0,mStreamDisplay = 0x0x40a8e828
12月4日至21日:38:28.321:E / QCameraHWI_ preVIEW(285):集previewWindow:电子
12月4日至21日:38:28.321:W / QCameraHWI_ preVIEW(285):设置为NULL preVIEW窗口
12月4日至21日:38:28.321:D / QCameraHWI(285):集previewWindow:X,M previewState = 0
12月4日至21日:38:28.321:D / QualcommCamera(285):Qint机器人:: start_ preVIEW(camera_device *):电子
12月4日至21日:38:28.331:D / QCameraHWI(285):安卓:: status_t机器人:: QCameraHardwareInterface ::启动preVIEW():M previewState = 0
12月4日至21日:38:28.331:D / QCameraHWI(285):安卓:: status_t机器人:: QCameraHardwareInterface ::启动preVIEW():HAL ::启动preVIEW开始
12月4日至21日:38:28.331:D / QCameraHWI(285):安卓:: status_t机器人:: QCameraHardwareInterface ::启动preVIEW():开始收preVIEW,但preVIEW窗口= NULL
12月4日至21日:38:28.331:D / QualcommCamera(285):Qint机器人:: start_ preVIEW(camera_device *):X
12月4日至21日:38:30.373:D / QualcommCamera(285):Qvoid机器人:: disable_msg_type(camera_device *,int32_t):电子
12月4日至21日:38:30.373:D / QCameraHWI(285):disableMsgType:X,MSGTYPE = 0x400的,mMsgEnabled = 0xd中
12月4日至21日:38:30.373:D / QCameraHWI(285):enableMsgType:X,MSGTYPE = 0x100的,mMsgEnabled = 0x10d
12月4日至21日:38:30.373:D / QualcommCamera(285):QChar则*的Andr​​oid :: get_parameters(camera_device *):电子
12月4日至21日:38:30.373:D / QualcommCamera(285):QChar则*的Andr​​oid :: get_parameters(camera_device *):X [1]
12月4日至21日:38:30.373:D / QualcommCamera(285):Qvoid机器人:: put_parameters(camera_device *,字符*):电子
12月4日至21日:38:30.384:D / QualcommCamera(285):Qint机器人:: take_picture(camera_device *):电子
12月4日至21日:38:30.384:D / QCameraHWI_Still(285):虚拟无效的Andr​​oid :: QCameraStream_Snapshot :: resetSnapshotCounters():被捕获的图像数量:1
12月4日至21日:38:30.384:E / QCameraHWI_Still(285):虚拟无效的Andr​​oid :: QCameraStream_Snapshot :: InitHdrInfoForSnapshot(BOOL,INT,INT *):number_frames = 1
12月4日至21日:38:30.914:W / SignalStrength(629):getLTELevel - RSRP:2147483647信噪比:2147483647 rsrpIconLevel:-1 snrIconLevel:-1
12月4日至21日:38:30.914:W / SignalStrength(823):getLTELevel - RSRP:2147483647信噪比:2147483647 rsrpIconLevel:-1 snrIconLevel:-1
12月4日至21日:38:30.914:W / SignalStrength(823):getLTELevel - RSSI:99 rssiIconLevel:0
12月4日至21日:38:30.914:W / SignalStrength(823):getTdScdmaLevel = 0
12月4日至21日:38:30.924:W / SignalStrength(823):getGsmLevel = 4
12月4日至21日:38:30.924:W / SignalStrength(823):getLevel = 4
12月4日至21日:38:30.924:W / SignalStrength(823):getLTELevel - RSRP:2147483647信噪比:2147483647 rsrpIconLevel:-1 snrIconLevel:-1
12月4日至21日:38:30.924:W / SignalStrength(629):getLTELevel - RSSI:99 rssiIconLevel:0
12月4日至21日:38:30.924:W / SignalStrength(823):getLTELevel - RSSI:99 rssiIconLevel:0
12月4日至21日:38:30.924:W / SignalStrength(629):getTdScdmaLevel = 0
12月4日至21日:38:30.924:W / SignalStrength(823):getTdScdmaLevel = 0
12月4日至21日:38:30.924:W / SignalStrength(629):getGsmLevel = 4
12月4日至21日:38:30.924:W / SignalStrength(629):getLevel = 4
12月4日至21日:38:30.924:W / SignalStrength(823):getGsmLevel = 4
12月4日至21日: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水平= 4
12月4日至21日:38:30.934:W / SignalStrength(823):getLevel = 4
12月4日至21日:38:30.934:W / SignalStrength(823):getLTELevel - RSRP:2147483647信噪比:2147483647 rsrpIconLevel:-1 snrIconLevel:-1
12月4日至21日:38:30.934:W / SignalStrength(823):getLTELevel - RSSI:99 rssiIconLevel:0
12月4日至21日:38:30.934:W / SignalStrength(823):getTdScdmaLevel = 0
12月4日至21日:38:30.934:W / SignalStrength(823):getGsmLevel = 4
12月4日至21日:38:30.934:W / SignalStrength(823):getLevel = 4
12月4日至21日:38:30.934:D / StatusBar.NetworkController(823):refreshViews连接= {}数据水平= 4 combinedSignalIconId = 0x7f0200a7 / com.android.systemui:绘制/ stat_sys_signal_4_fully combinedActivityIconId = 0x7f0200a8 mobileLabel = Airtel公司wifiLabel = emergencyOnly =假combinedLabel = Airtel公司mAirplaneMode =假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
12月4日至21日:38:40.144:D / PowerManagerService(629):[PMS] nominalCurrentValue = 145 =亮度20级= 77
12月4日至21日:38:47.161:D / PowerManagerService(629):[PMS] updateLightsLocked:newState = 0 / forceState = 0
12月4日至21日:38:47.161:D / PowerManagerService(629):[PMS] nominalCurrentValue = 20的亮度= 0步骤= 12
12月4日至21日:38:47.342:I / AlarmManager(629):触发警报{432ca750类型0 com.appbell.pml.user.ui} [类型= 0时,=(2014年4月21日12时38分47秒) repeatInt = 30000的PendingIntent {42d95b90:PendingIntentRecord {432cca18 com.appbell.pml.user.ui startService}}]
12月4日至21日:38:47.662:I / VibratorService(629):service.runit.start:0
12月4日至21日:38:47.682:I / NotificationService(629):FXN.ASD] NMS:mInCall = FALSE / mScreenOn = FALSE / mLedNotification = NULL
12月4日至21日:38:47.682:I / NotificationService(629):FXN.ASD] NMS:关闭LED
12月4日至21日:38:47.692:D / AudioHardwareALSA(285):setParameters()screen_state =关闭
12月4日至21日:38:47.692:V / AudioHardwareALSA(285):__start组麦克风
12月4日至21日:38:47.692:V / AudioHardwareALSA(285):__start集HAC参数
12月4日至21日:38:47.762:D / AccelerometerListener(888):使能(假)
12月4日至21日:38:47.772:D / NfcService(904):NFC-C,断开
12月4日至21日:38:47.772:D / NFC_LIST(904):分配的节点:0x5dd92420(0x60833c5c)
12月4日至21日:38:47.782:I / PhoneLedService(888):mPhoneLedReceiver的onReceive():android.intent.action.SCREEN_OFF
12月4日至21日:38:47.782:D / NFCJNI(904):******停止NFC发现******
12月4日至21日:38:47.802:D / NFCJNI(904):phLibNfc_Mgt_ConfigureDiscovery(-----,CE-0-493e0)返回0x0000000d
12月4日至21日:38:47.822:D / NFCJNI(904):回调:nfc_jni_discover_callback() - 状态= 0×0000 [NFCSTATUS_SUCCESS]
12月4日至21日:38:47.822:D / NFC_LIST(904):解除分配节点:0x5dd92420(0x60833c5c)
12月4日至21日:38:47.822:V / SuperStamina-XssmReminder(629):onScreenOn:假的
12月4日至21日:38:47.822:V / SuperStamina-XssmReminder(629):...状态:xssmOn =假插= TRUE关闭= 0
12月4日至21日:38:47.872:D / YouTube的MDX(6902):收到意向android.intent.action.SCREEN_OFF
12月4日至21日:38:48.092:W / ActivityManager(629):为ActivityRecord活动暂停超时{42925e38 com.appbell.pml.user.ui / com.appbell.and.common.util.CustomAlertDialog}
12月4日至21日:38:49.274:I / AlarmManager(629):触发警报{434208d8 2型com.google.android.gms} [类型= 2时=(2014年4月21日12时38分49秒)repeatInt = 0 {的PendingIntent 43321f48:PendingIntentRecord {42b756b0 com.google.android.gms broadcastIntent}}]
 12月4日至21日:38:51.686:I / BatteryService(629):启动UEVENT更新,事件= {子系统= POWER_SUPPLY,DEVPATH = /设备/平台/ msm_ssbi.0 / pm8038核心/ pm8921充电器/ POWER_SUPPLY /电池, POWER_SUPPLY_HEALTH =好,POWER_SUPPLY_STATUS =充电,POWER_SUPPLY_TECHNOLOGY =锂离子电池,POWER_SUPPLY_ENERGY_FULL = 1743000,POWER_SUPPLY_VOLTAGE_MIN_DESIGN = 320万,POWER_SUPPLY_TEMP = 374,POWER_SUPPLY_ preSENT = 1,POWER_SUPPLY_NAME =电池,POWER_SUPPLY_CHARGE_NOW = -33712,POWER_SUPPLY_CURRENT_MAX = 3381843,POWER_SUPPLY_CAPACITY = 87 ,POWER_SUPPLY_VOLTAGE_MAX_DESIGN = 420,SEQNUM = 26702,POWER_SUPPLY_CURRENT_NOW = -457700,POWER_SUPPLY_VOLTAGE_NOW = 4092957,ACTION =变化,POWER_SUPPLY_CHARGE_TYPE =快速}
12月4日至21日:38:52.577:I / AlarmManager(629):触发警报{43611128 2型机器人} [类型= 2时=(2014年4月21日12点38分52秒)repeatInt = 0的PendingIntent {43756cc8:PendingIntentRecord {43616a60的Andr​​oid broadcastIntent}}]
12月4日至21日:38:52.597:W / ActivityManager(629):睡眠超时!现在睡觉。
12月4日至21日:38:52.968:D / -heap(4337):GC_CONCURRENT释放2869K,9291K无/ 17027K 46%,暂停16ms的+ 8ms的,共有150毫秒
12月4日至21日:38:55.701:I / BatteryService(629):启动UEVENT更新,事件= {子系统= POWER_SUPPLY,DEVPATH = /设备/平台/ msm_ssbi.0 / pm8038核心/ pm8921充电器/ POWER_SUPPLY /电池, POWER_SUPPLY_HEALTH =好,POWER_SUPPLY_STATUS =充电,POWER_SUPPLY_TECHNOLOGY =锂离子电池,POWER_SUPPLY_ENERGY_FULL = 1743000,POWER_SUPPLY_VOLTAGE_MIN_DESIGN = 320万,POWER_SUPPLY_TEMP = 374,POWER_SUPPLY_ preSENT = 1,POWER_SUPPLY_NAME =电池,POWER_SUPPLY_CHARGE_NOW = -34218,POWER_SUPPLY_CURRENT_MAX = 3381843,POWER_SUPPLY_CAPACITY = 88 ,POWER_SUPPLY_VOLTAGE_MAX_DESIGN = 420,SEQNUM = 26703,POWER_SUPPLY_CURRENT_NOW = -460600,POWER_SUPPLY_VOLTAGE_NOW = 4094421,ACTION =变化,POWER_SUPPLY_CHARGE_TYPE =快速}
12月4日至21日:38:55.731:V / SuperStamina-XssmReminder(629):onBatteryChanged:插=真
12月4日至21日:38:55.731:V / SuperStamina-PowerSaveReminder(629):onBatteryChanged:级别= 88 =插入真
12月4日至21日:38:55.731:V / SuperStamina-PowerSaveReminder(629):...状态:启用=假mPlugged =真mUnpluggedTime = 0 mUnpluggedLevel = 0
12月4日至21日:38:58.103:W / ActivityManager(629):为ActivityRecord活动停止超时{42a7d8e0 com.appbell.pml.user.ui / com.appbell.and.pml.ca.app.ui.DashboardActivity}
12月4日至21日:38:58.103:W / ActivityManager(629):为ActivityRecord活动停止超时{42925e38 com.appbell.pml.user.ui / com.appbell.and.common.util.CustomAlertDialog}
12月4日至21日:39:09.806:I / AlarmManager(629):触发警报{429b7c28 2型com.google.android.gms} [类型= 2时=(2014年4月21日12时39分09秒)repeatInt = 0 {的PendingIntent 429edb18:PendingIntentRecord {429d5300 com.google.android.gms broadcastIntent}}]
12月4日至21日:39:09.826:D /的StateMachine(629):的handleMessage:电子msg.what = 131084
12月4日至21日:39:09.826:D /的StateMachine(629):processMsg:DriverUnloadedState
12月4日至21日:39:09.826:D / WifiStateMachine(629):DriverUnloadedState {=什么时候131084 = -2ms}
12月4日至21日:39:09.826:D /的StateMachine(629):processMsg:DefaultState
12月4日至21日:39:09.826:D / WifiStateMachine(629):DefaultState {=什么时候131084 = -4ms}
12月4日至21日:39:09.836:D /的StateMachine(629):的handleMessage:X
12月4日至21日:39:09.836:D /的StateMachine(629):的handleMessage:电子msg.what = 131074
12月4日至21日:39:09.836:D /的StateMachine(629):processMsg:DriverUnloadedState
12月4日至21日:39:09.836:D / WifiStateMachine(629):DriverUnloadedState {=什么时候131074 = -9ms ARG1 = 1}
12月4日至21日:39:09.836:D /的StateMachine(629):processMsg:DefaultState
12月4日至21日:39:09.836:D / WifiStateMachine(629):DefaultState {=什么时候131074 = -11ms ARG1 = 1}
12月4日至21日:39:09.836:D /的StateMachine(629):的handleMessage:X
12月4日至21日:39:09.876:D /的StateMachine(629):的handleMessage:电子msg.what = 131084
12月4日至21日:39:09.876:D /的StateMachine(629):processMsg:DriverUnloadedState
12月4日至21日:39:09.876:D / WifiStateMachine(629):DriverUnloadedState {=什么时候131084 = -2ms}
12月4日至21日:39:09.876:D /的StateMachine(629):processMsg:DefaultState
12月4日至21日:39:09.876:D / WifiStateMachine(629):DefaultState {=什么时候131084 = -5ms}
12月4日至21日:39:09.876:D /的StateMachine(629):的handleMessage:X
12月4日至21日:39:09.876:D /的StateMachine(629):的handleMessage:电子msg.what = 131074
12月4日至21日:39:09.886:D /的StateMachine(629):processMsg:DriverUnloadedState
12月4日至21日:39:09.886:D / WifiStateMachine(629):DriverUnloadedState {=什么时候131074 = -10ms ARG1 = 1}
12月4日至21日:39:09.886:D /的StateMachine(629):processMsg:DefaultState
12月4日至21日:39:09.886:D / WifiStateMachine(629):DefaultState {=什么时候131074 = -13ms ARG1 = 1}
12月4日至21日:39:09.886:D /的StateMachine(629):的handleMessage:X
12月4日至21日:39:14.150:E / MyCamera(7591):takePicture失败
12月4日至21日:39:15.081:D / QualcommCamera(285):Qvoid机器人:: disable_msg_type(camera_device *,int32_t):电子
12月4日至21日:39:15.081:D / QCameraHWI(285):disableMsgType:X,MSGTYPE = 0x400的,mMsgEnabled = 0x10d
12月4日至21日:39:15.081:D / QualcommCamera(285):Qvoid机器人:: disable_msg_type(camera_device *,int32_t):电子
12月4日至21日:39:15.081:D / QCameraHWI(285):disableMsgType:X,MSGTYPE = 0×10,mMsgEnabled = 0x10d
12月4日至21日:39:15.081:D / QualcommCamera(285):Qvoid机器人:: disable_msg_type(camera_device *,int32_t):电子
12月4日至21日:39:15.081:D / QCameraHWI(285):disableMsgType:X,MSGTYPE = 0x3c2,mMsgEnabled = 0xd中
12月4日至21日:39:15.081:D / QualcommCamera(285):Qvoid机器人:: stop_ preVIEW(camera_device *):电子
12月4日至21日:39:15.081:D / QCameraHWI(285):无效的Andr​​oid :: QCameraHardwareInterface ::停止preVIEW():停止preVIEW:电子
12月4日至21日:39:15.081:E / MM-libcamera2(285):资料HAL:停止preVIEW():E:1398064155.095584038
12月4日至21日:39:15.091:D / QCameraHWI(285):停止preVIEW:X,M previewState = 0
12月4日至21日:39:15.462:D / QualcommCamera(285):Qint机器人:: recording_enabled(camera_device *):电子
12月4日至21日:39:15.672:W / CameraService(285):尝试使用锁定的相机从不同的进程(旧PID 0,新的PID 7591)
12月4日至21日:39:15.672:W / CameraService(285):尝试使用锁定的相机从不同的进程(旧PID 0,新的PID 7591)
12月4日至21日:39:15.672:W / CameraService(285):不同的客户端 - 不要断开连接
12月4日至21日:39:17.344:I / AlarmManager(629):触发警报{432ca750类型0 com.appbell.pml.user.ui} [类型= 0时,=(2014年4月21日12时39分17秒) repeatInt = 30000的PendingIntent {42d95b90:PendingIntentRecord {432cca18 com.appbell.pml.user.ui startService}}]
12月4日至21日:39:17.394:W / ActivityManager(629):超时执行服务:ServiceRecord {436caf28 com.appbell.pml.user.ui / com.appbell.and.pml.ca.app.service.LocationCaptureMonitorService}
12月4日至21日:39:18.154:I / AlarmManager(629):触发警报{42a95700 2型com.google.android.gms} [类型= 2时=(2014年4月21日12时39分17秒)repeatInt = 0 {的PendingIntent 42af8fc8:PendingIntentRecord {42b1ca58 com.google.android.gms broadcastIntent}}]
12月4日至21日:39:18.154:I / AlarmManager(629):触发警报{43439cc8 2型com.google.android.gsf} [类型= 2时=(1970-01-01 5点30分零零秒)repeatInt = 0 {的PendingIntent 42aeabc8:PendingIntentRecord {43133218 com.google.android.gsf broadcastIntent}}]
12月4日至21日:39:18.695:D / -heap(629):GC_CONCURRENT释放2742K,17516K自由/ 27143K 36%,暂停14ms的11毫秒+,128毫秒总
12月4日至21日:39:18.705:D / dalvikvm(629):WAIT_FOR_CONCURRENT_GC受阻89ms
12月4日至21日:39:18.905:D / dalvikvm(629):WAIT_FOR_CONCURRENT_GC受阻0毫秒
12月4日至21日:39:19.045:D / -heap(629):GC_EXPLICIT释放875K,免费17700K / 27143K 35%,暂停6ms的11毫秒+,总134ms
12月4日至21日:39:19.606:E / ActivityManager(629):ANR在com.appbell.pml.user.ui
12月4日至21日:39:19.606:E / ActivityManager(629):原因:执行服务com.appbell.pml.user.ui / com.appbell.and.pml.ca.app.service.LocationCaptureMonitorService
12月4日至21日:39:19.606:E / ActivityManager(629):负载:2.39 / 9.61 / 8.39
12月4日至21日:39:19.606:E / ActivityManager(629):从12396ms CPU使用率前2577ms:
12月4日至21日:39:19.606:E / ActivityManager(629):0.9%,629 / system_server:0.3%的用户+ 0.6%,核心/故障:43轻微
12月4日至21日:39:19.606:E / ActivityManager(629):0.1%,372 / adbd:0%用户+ 0.1%的内核
12月4日至21日:39:19.606:E / ActivityManager(629):0.2%,3160 / mpdecision:0%用户+ 0.2%的内核
12月4日至21日:39:19.606:E / ActivityManager(629):0.2%,4337 / com.google.process.location:0.1%的用户+ 0.1%,核心/故障:2人轻伤
12月4日至21日:39:19.606:E / ActivityManager(629):0%281 / RILD:0%用户+ 0%,核心/故障:2人轻伤
12月4日至21日:39:19.606:E / ActivityManager(629):0.1%,4807 / com.sonymobile.playanywhere:0%用户+ 0.1%的内核
12月4日至21日:39:19.606:E / ActivityManager(629):0%5144 / kworker / 0:0:0%用户+ 0%内核
12月4日至21日:39:19.606:E / ActivityManager(629):0%7185 / logcat中:0%用户+ 0%内核
12月4日至21日:39:19.606:E / ActivityManager(629):1.6%总计:0.5%的用户+ 1.1%的内核
12月4日至21日:39:19.606:E / ActivityManager(629):从1653ms CPU使用率后2180ms:
12月4日至21日:39:19.606:E / ActivityManager(629):3.7%,629 / system_server:0%用户+ 3.7%的内核
12月4日至21日:39:19.606:E / ActivityManager(629):5.6%683 / ActivityManager:0%用户+ 5.6%的内核
12月4日至21日:39:19.606:E / ActivityManager(629):2.5%总计:0%用户+ 2.5%的内核
12月4日至21日:39:19.616:D / ActivityManager(629):看了/data/anr/traces_com.appbell.pml.user.ui.txt
12月4日至21日:39:20.687:D / QualcommCamera(285):Qvoid机器人:: disable_msg_type(camera_device *,int32_t):电子
12月4日至21日:39:20.687:D / QCameraHWI(285):disableMsgType:X,MSGTYPE = 0xFFFF的,mMsgEnabled =为0x0
12月4日至21日:39:20.687:D / QualcommCamera(285):Qvoid机器人:: stop_ preVIEW(camera_device *):电子
12月4日至21日:39:20.687:D / QCameraHWI(285):无效的Andr​​oid :: QCameraHardwareInterface ::停止preVIEW():停止preVIEW:电子
12月4日至21日:39:20.687:E / MM-libcamera2(285):资料HAL:停止preVIEW():E:1398064160.698422433
12月4日至21日:39:20.687:D / QCameraHWI(285):停止preVIEW:X,M previewState = 0
12月4日至21日:39:20.687:D / QualcommCamera(285):Qint机器人:: cancel_picture(camera_device *):电子
12月4日至21日:39:20.687:D / QCameraHWI(285):cancelPicture:电子
12月4日至21日:39:20.687:D / QCameraHWI(285):cancelPicture:X
12月4日至21日:39:20.687:D / QualcommCamera(285):Qvoid机器人::发布(camera_device *):电子
12月4日至21日:39:20.687:D / QCameraHWI(285):发布:电子
 12月4日至21日:39:20.687:D / QCameraHWI(285):发布:X
12月4日至21日:39:20.687:D / QualcommCamera(285):Qint机器人:: close_camera_device(hw_device_t *):设备= 0x4224edd8Ë
12月4日至21日:39:20.687:D / QCameraHWI(285):〜QCameraHardwareInterface:电子
12月4日至21日:39:20.687:E / QCameraHWI_ preVIEW(285):虚拟无效的Andr​​oid :: QCameraStream_ preVIEW ::版本():BEGIN
12月4日至21日:39:20.687:E / QCameraHWI_ preVIEW(285):调试:虚拟无效的Andr​​oid :: QCameraStream_ preVIEW ::版本():德初始化通道
 12月4日至21日:39:20.687:E / MM-libcamera2(285):mm_camera_ch_util_reg_buf_cb:尝试注册
 12月4日至21日:39:20.687:E / MM-libcamera2(285):mm_camera_ch_util_reg_buf_cb:完成注册
 12月4日至21日:39:20.687:E / QCameraHWI_ preVIEW(285):虚拟无效的Andr​​oid :: QCameraStream_ preVIEW ::版本():END
12月4日至21日:39:20.687:E / MM-libcamera2(285):mm_camera_ch_util_reg_buf_cb:尝试注册
 12月4日至21日:39:20.687:E / MM-libcamera2(285):mm_camera_ch_util_reg_buf_cb:完成注册
 12月4日至21日:39:20.687:V / QCameraHWI_Still(285):虚拟无效的Andr​​oid :: QCameraStream_Snapshot ::版本():电子
12月4日至21日:39:20.687:V / QCameraHWI_Still(285):虚拟无效的Andr​​oid :: QCameraStream_Snapshot ::版本():X
12月4日至21日:39:20.697:V / QCameraHWI_Still(285):虚拟机器人:: QCameraStream_Snapshot ::〜QCameraStream_Snapshot():电子
12月4日至21日:39:20.697:I / MM-仍然OMX(285):omxJpegClose:
12月4日至21日:39:20.697:V / QCameraHWI_Still(285):虚拟机器人:: QCameraStream_Snapshot ::〜QCameraStream_Snapshot():X
12月4日至21日:39:20.697:E /毫米相机(300):config_shutdown_pp相机不在流模式。返回。
12月4日至21日:39:20.697:E /毫米相机(300):mctl_release:set_params(SENSOR_SET_STOP_STREAM)
12月4日至21日:39:20.697:E /毫米相机(300):vfe_ops_deinit:电子
12月4日至21日:39:20.707:D / QCameraHWI(285):〜QCameraHardwareInterface:X
12月4日至21日:39:20.707:D / QualcommCamera(285):Qint机器人:: close_camera_device(hw_device_t *):X:camera_count = 0


解决方案

最后,我加入解决了表面纹理的问题,并设置previewTexture ....

请注意:结果
在低于4.0使用道具SurfaceView版本。结果
在版本> = 4.0使用表面纹理(和setSurfaceTexture()),而不是SurfaceView的。

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

I know this question has been asked many times but none of the answers has solved my question. In my app, I have used service which takes picture without preview in a background. My app works fine on most of the Android phones like Samsung Galaxy S2, Samsung Grand but when I tested on Sony Experia M 4.1.2 and Samsung Galaxy Core Duos 4.1.2, it throws runtime exception at myCamera.takePicture.

I have followed many links on stackoverflow but couldnt find solution:

This is my code:

@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) {
                }
            }
        }
    }
};

Stacktrace:

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
解决方案

Finally I solved the issue by adding SurfaceTexture and setPreviewTexture....

Note:
In version below 4.0 use dummy SurfaceView.
In versions >= 4.0 use of SurfaceTexture (and setSurfaceTexture()) instead of SurfaceView.

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

这篇关于Camera.takePicture抛出的RuntimeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 08:48