Android:相机不会拍照

时间:2013-01-10 12:16:55

标签: android camera

拍摄照片的代码挂在takePicture上。该代码适用于运行Android 2.2或4.0的设备。它运行在运行2.3的华为上。目前我不确定它是设备还是API。我怀疑该设备,但发现这很奇怪,因为系统相机应用程序工作。这是我在执行takePicture方法时记录的LogCat条目。是否有人能够发现可能会提示的内容?

01-10 13:09:42.589: I/QualcommCameraHardware(113): Found a matching camera info for ID 0
01-10 13:09:42.589: I/QualcommCameraHardware(113): HAL_getCameraInfo: orientation = 90
01-10 13:09:42.589: I/QualcommCameraHardware(113): HAL_getCameraInfo: modes supported = 5
01-10 13:09:42.599: I/QualcommCameraHardware(113): openCameraHardware: call createInstance
01-10 13:09:42.599: I/QualcommCameraHardware(113): openCameraHardware:Valid camera ID 0
01-10 13:09:42.599: I/QualcommCameraHardware(113): openCameraHardware:camera mode 1
01-10 13:09:42.599: I/QualcommCameraHardware(113): HAL_openCameraHardware: HAL_currentSnapshotMode = 4
01-10 13:09:42.599: I/QualcommCameraHardware(113): createInstance: E
01-10 13:09:42.599: I/QualcommCameraHardware(113): QualcommCameraHardware constructor E
01-10 13:09:42.619: I/QualcommCameraHardware(113): createInstance: created hardware=0x10a68
01-10 13:09:42.759: E/CAM_FD(113): sensor_load_chromatix: Sensor name: s5k5ca cnt=3
01-10 13:09:42.759: E/mm-camera(113): s5k5ca_setup_camctrl_tbl:get af supported false!
01-10 13:09:42.769: E/mm-camera(113): camera_query_parms: pict_max_size   max_width 2048 max_height 1536
01-10 13:09:42.769: E/QualcommCameraHardware(113): startCamera X: max pic   width:2048   height:1536
01-10 13:09:42.769: I/QualcommCameraHardware(113): initDefaultParameters E
01-10 13:09:42.859: I/QualcommCameraHardware(113): AutoFocus is not supported
01-10 13:09:42.859: E/QualcommCameraHardware(113): filterPictureSizes   picture_sizes[3].width:2048  picture_sizes[3].height:1536 .
01-10 13:09:42.869: E/QualcommCameraHardware(113): Maximum zoom value is 61
01-10 13:09:42.869: I/QualcommCameraHardware(113): initDefaultParameters: setting num-snaps-per-shutter to 1
01-10 13:09:42.869: I/QualcommCameraHardware(113): setRecordSize: preview dimensions: 640x480
01-10 13:09:42.869: I/QualcommCameraHardware(113): setRecordSize: video dimensions: 640x480
01-10 13:09:42.869: I/QualcommCameraHardware(113): Parameter Rolloff is not supported for this sensor
01-10 13:09:42.869: I/QualcommCameraHardware(113): Parameter MCE is not supported for this sensor
01-10 13:09:42.869: I/QualcommCameraHardware(113): Sharpness not supported for this sensor
01-10 13:09:42.869: I/QualcommCameraHardware(113): Saturation not supported for this sensor
01-10 13:09:42.869: E/QualcommCameraHardware(113): Parameter Scenemode is not supported for this sensor
01-10 13:09:42.869: I/QualcommCameraHardware(113): Contrast not supported for this sensor
01-10 13:09:42.879: I/QualcommCameraHardware(113): Parameter AntiBanding is not supported for this sensor
01-10 13:09:42.879: I/QualcommCameraHardware(113): setRedeyeReduction: setting Redeye Reduction value of disable
01-10 13:09:42.879: E/CAM_FD(113): config_proc_CAMERA_SET_REDEYE_REDUCTION: mode =0
01-10 13:09:42.879: E/CAM_FD(113): config_proc_CAMERA_SET_REDEYE_REDUCTION: FAILED
01-10 13:09:42.879: E/QualcommCameraHardware(113): native_set_parms failed: type 50 length 1 error No such file or directory
01-10 13:09:42.879: E/QualcommCameraHardware(113): Wavelet Denoise is not supported for this sensor
01-10 13:09:42.879: E/QualcommCameraHardware(113): FPS Range Values: 5000x31000
01-10 13:09:42.879: I/QualcommCameraHardware(113): Set fps is not supported for this sensor
01-10 13:09:42.879: I/QualcommCameraHardware(113): set fps mode is not supported for this sensor
01-10 13:09:42.879: I/QualcommCameraHardware(113): Auto Exposure not supported for this sensor
01-10 13:09:42.879: I/QualcommCameraHardware(113): Exposure Compensation is not supported for this sensor
01-10 13:09:42.879: I/QualcommCameraHardware(113): setFlash: flash not supported
01-10 13:09:42.879: I/QualcommCameraHardware(113): Set Brightness not supported for this sensor
01-10 13:09:42.879: E/QualcommCameraHardware(113): Parameter ISO Value is not supported for this sensor
01-10 13:09:42.879: I/QualcommCameraHardware(113): setHighFrameRate: setting HFR value of off(1)
01-10 13:09:42.879: I/QualcommCameraHardware(113): initDefaultParameters X
01-10 13:09:42.879: I/QualcommCameraHardware(113): createInstance: X
01-10 13:09:42.879: I/QualcommCameraHardware(113): Found a matching camera info for ID 0
01-10 13:09:42.879: I/QualcommCameraHardware(113): HAL_getCameraInfo: orientation = 90
01-10 13:09:42.879: I/QualcommCameraHardware(113): HAL_getCameraInfo: modes supported = 5
01-10 13:09:42.879: E/CameraService(113): takePicture   return mHardware->takePicture(mSurface)
01-10 13:09:42.879: E/QualcommCameraHardware(113): takePicture(2511)
01-10 13:09:42.879: E/mm-camera(113): PROFILE Camera_interface pre_prepare snap : 1357819782.890308291
01-10 13:09:42.879: E/mm-camera(113): PROFILE Camera_interface post prepare_snap: 1357819782.890339957
01-10 13:09:42.879: I/QualcommCameraHardware(113): stopPreviewInternal E: 0
01-10 13:09:42.879: I/QualcommCameraHardware(113): stopPreviewInternal X: 0
01-10 13:09:42.899: D/MediaPlayer(113): setDataSource(/system/media/audio/ui/camera_click.ogg)
01-10 13:09:42.899: E/QualcommCameraHardware(113): initRaw   getPictureSize   mPictureWidth:640   mPictureHeight:480
01-10 13:09:42.899: E/mm-camera(113): camera_set_parms  CAMERA_PARM_NEED_TO_RESIZE   *((bool*)p_value):0
01-10 13:09:42.909: E/mm-camera(113): snapshot_set_need_resize: exit status 0,  is_need_resize:0
01-10 13:09:42.909: E/QualcommCameraHardware(113): rawsize = 460800 cbcr offset =307200
01-10 13:09:42.909: V/MediaPlayerService(113): Client(1) constructor
01-10 13:09:42.909: V/MediaPlayerService(113): Create new client(1) from pid 113, url=/system/media/audio/ui/camera_click.ogg, connId=1, audioSessionId=3
01-10 13:09:42.909: D/MediaPlayerService(113): setDataSource(/system/media/audio/ui/camera_click.ogg)
01-10 13:09:42.929: V/MediaPlayerService(113): usePVPlayer: did not detect file to be with LPA implementation
01-10 13:09:42.929: I/MediaPlayerService(113): The Default player that is returned is STAGEFRIGHT**************
01-10 13:09:42.929: V/MediaPlayerService(113): player type = 4
01-10 13:09:42.929: V/MediaPlayerService(113):  create StagefrightPlayer
01-10 13:09:42.939: V/AudioSink(113): AudioOutput(3)
01-10 13:09:42.939: V/MediaPlayerService(113):  setDataSource
01-10 13:09:42.939: V/MediaPlayerService(113): [1] setAudioStreamType(10)
01-10 13:09:42.939: V/MediaPlayerService(113): [1] prepareAsync
01-10 13:09:42.989: V/MediaPlayerService(113): [1] notify (0x16e78, 5, 0, 0)
01-10 13:09:42.989: V/MediaPlayerService(113): [1] notify (0x16e78, 1, 0, 0)
01-10 13:09:42.989: D/MediaPlayer(113): setDataSource(/system/media/audio/ui/VideoRecord.ogg)
01-10 13:09:42.989: V/MediaPlayerService(113): Client(2) constructor
01-10 13:09:42.989: V/MediaPlayerService(113): Create new client(2) from pid 113, url=/system/media/audio/ui/VideoRecord.ogg, connId=2, audioSessionId=4
01-10 13:09:42.989: D/MediaPlayerService(113): setDataSource(/system/media/audio/ui/VideoRecord.ogg)
01-10 13:09:42.989: V/MediaPlayerService(113): usePVPlayer: did not detect file to be with LPA implementation
01-10 13:09:42.989: I/MediaPlayerService(113): The Default player that is returned is STAGEFRIGHT**************
01-10 13:09:42.989: V/MediaPlayerService(113): player type = 4
01-10 13:09:42.989: V/MediaPlayerService(113):  create StagefrightPlayer
01-10 13:09:42.999: V/AudioSink(113): AudioOutput(4)
01-10 13:09:42.999: V/MediaPlayerService(113):  setDataSource
01-10 13:09:42.999: V/MediaPlayerService(113): [2] setAudioStreamType(10)
01-10 13:09:42.999: V/MediaPlayerService(113): [2] prepareAsync
01-10 13:09:43.009: V/MediaPlayerService(113): [2] notify (0x254e8, 5, 0, 0)
01-10 13:09:43.009: V/MediaPlayerService(113): [2] notify (0x254e8, 1, 0, 0)
01-10 13:09:48.909: E/CAM_FD(113): ...config thread select timeout...
01-10 13:09:48.969: D/PowerManagerService(199): acquireWakeLock flags=0x1 tag=SyncManagerHandleSyncAlarm
01-10 13:09:48.979: D/PowerManagerService(199): acquireWakeLock flags=0x1 tag=AlarmManager
01-10 13:09:48.979: D/PowerManagerService(199): releaseWakeLock flags=0x1 tag=AlarmManager
01-10 13:09:48.979: D/PowerManagerService(199): releaseWakeLock flags=0x1 tag=SyncManagerHandleSyncAlarm
01-10 13:09:54.919: E/CAM_FD(113): ...config thread select timeout...
01-10 13:09:59.999: D/PowerManagerService(199): acquireWakeLock flags=0x1 tag=AlarmManager
01-10 13:10:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver onReceive
01-10 13:10:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver actionandroid.intent.action.TIME_TICK
01-10 13:10:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver msg.what=1001
01-10 13:10:00.039: I/WeatherMediumWidgetProvider(732): updateUI(Context context)
01-10 13:10:00.049: D/WeatherMediumWidgetProvider(732): updateUI(Context context, AppWidgetManager widgetManager, int[] appWidgetId)
01-10 13:10:00.059: D/WidgetUtils(732): setWeatherHomeClickListener
01-10 13:10:00.059: D/PowerManagerService(199): releaseWakeLock flags=0x1 tag=AlarmManager
01-10 13:10:00.069: D/WidgetUtils(732): setWeatherHomeClickListener
01-10 13:10:00.069: D/WidgetUtils(732): setAlarmClockClickListener
01-10 13:10:00.069: D/WidgetUtils(732): setAlarmClockClickListener
01-10 13:10:00.069: D/WidgetUtils(732): setWeatherUpdateClickListener
01-10 13:10:00.069: D/WidgetUtils(732): setAccuWeatherCickListener
01-10 13:10:00.069: E/WidgetUtils(732): cityCode=cityId:167705
01-10 13:10:00.069: D/WidgetUtils(732): updateWeatherInfo
01-10 13:10:00.069: D/Utils(732): isDataOK
01-10 13:10:00.069: D/Utils(732): dataOverdue
01-10 13:10:00.069: D/WidgetUtils(732): updateWeatherInfo temperature =3.3333333,time1357482579481,weatherDes=Mostly Cloudy,invalidDay=4
01-10 13:10:00.069: D/WidgetUtils(732): updateWeatherInfo weatherDayDataInfo =HighTemperature =3.3333333 LowTemperature =-0.5555556 WeatherIcon =7 TextShort=Cloudy and colder TextLong=Cloudy and colder with a rain and snow shower possible WindSpeed=5 WindDirection=W
01-10 13:10:00.079: D/WidgetUtils(732): updateCityDateTime 
01-10 13:10:00.079: D/WidgetUtils(732): getCurCityCalendar
01-10 13:10:00.079: D/WidgetUtils(732): builder=2013/01/10  Thursday,dayOfWeek=Thursday,dayFormat=2013/01/10
01-10 13:10:00.079: D/WidgetUtils(732): calender2ClockImgIdx
01-10 13:10:00.079: D/WidgetUtils(732): updateRefreshTime
01-10 13:10:00.079: D/Utils(732): isUpdating
01-10 13:10:00.079: D/Utils(732): isDataOK
01-10 13:10:00.079: D/Utils(732): dataOverdue
01-10 13:10:00.089: D/WidgetUtils(732): getUpdateTime relativeDay=4
01-10 13:10:00.929: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:06.929: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:12.939: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:18.939: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:24.939: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:30.949: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:36.959: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:42.959: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:48.969: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:54.979: E/CAM_FD(113): ...config thread select timeout...
01-10 13:10:59.999: D/PowerManagerService(199): acquireWakeLock flags=0x1 tag=AlarmManager
01-10 13:11:00.029: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver onReceive
01-10 13:11:00.029: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver actionandroid.intent.action.TIME_TICK
01-10 13:11:00.029: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver msg.what=1001
01-10 13:11:00.029: I/WeatherMediumWidgetProvider(732): updateUI(Context context)
01-10 13:11:00.029: D/WeatherMediumWidgetProvider(732): updateUI(Context context, AppWidgetManager widgetManager, int[] appWidgetId)
01-10 13:11:00.039: D/WidgetUtils(732): setWeatherHomeClickListener
01-10 13:11:00.039: D/WidgetUtils(732): setWeatherHomeClickListener
01-10 13:11:00.049: D/WidgetUtils(732): setAlarmClockClickListener
01-10 13:11:00.049: D/WidgetUtils(732): setAlarmClockClickListener
01-10 13:11:00.059: D/WidgetUtils(732): setWeatherUpdateClickListener
01-10 13:11:00.059: D/WidgetUtils(732): setAccuWeatherCickListener
01-10 13:11:00.059: E/WidgetUtils(732): cityCode=cityId:167705
01-10 13:11:00.059: D/WidgetUtils(732): updateWeatherInfo
01-10 13:11:00.059: D/Utils(732): isDataOK
01-10 13:11:00.059: D/Utils(732): dataOverdue
01-10 13:11:00.059: D/PowerManagerService(199): releaseWakeLock flags=0x1 tag=AlarmManager
01-10 13:11:00.069: D/WidgetUtils(732): updateWeatherInfo temperature =3.3333333,time1357482579481,weatherDes=Mostly Cloudy,invalidDay=4
01-10 13:11:00.069: D/WidgetUtils(732): updateWeatherInfo weatherDayDataInfo =HighTemperature =3.3333333 LowTemperature =-0.5555556 WeatherIcon =7 TextShort=Cloudy and colder TextLong=Cloudy and colder with a rain and snow shower possible WindSpeed=5 WindDirection=W
01-10 13:11:00.069: D/WidgetUtils(732): updateCityDateTime 
01-10 13:11:00.069: D/WidgetUtils(732): getCurCityCalendar
01-10 13:11:00.069: D/WidgetUtils(732): builder=2013/01/10  Thursday,dayOfWeek=Thursday,dayFormat=2013/01/10
01-10 13:11:00.069: D/WidgetUtils(732): calender2ClockImgIdx
01-10 13:11:00.069: D/WidgetUtils(732): updateRefreshTime
01-10 13:11:00.069: D/Utils(732): isUpdating
01-10 13:11:00.069: D/Utils(732): isDataOK
01-10 13:11:00.069: D/Utils(732): dataOverdue
01-10 13:11:00.069: D/WidgetUtils(732): getUpdateTime relativeDay=4
01-10 13:11:00.979: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:06.989: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:12.989: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:18.999: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:24.999: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:31.009: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:37.009: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:43.009: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:49.019: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:55.019: E/CAM_FD(113): ...config thread select timeout...
01-10 13:11:59.999: D/PowerManagerService(199): acquireWakeLock flags=0x1 tag=AlarmManager
01-10 13:12:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver onReceive
01-10 13:12:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver actionandroid.intent.action.TIME_TICK
01-10 13:12:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver msg.what=1001
01-10 13:12:00.039: I/WeatherMediumWidgetProvider(732): updateUI(Context context)
01-10 13:12:00.049: D/WeatherMediumWidgetProvider(732): updateUI(Context context, AppWidgetManager widgetManager, int[] appWidgetId)
01-10 13:12:00.049: D/WidgetUtils(732): setWeatherHomeClickListener
01-10 13:12:00.049: D/WidgetUtils(732): setWeatherHomeClickListener
01-10 13:12:00.049: D/WidgetUtils(732): setAlarmClockClickListener
01-10 13:12:00.049: D/WidgetUtils(732): setAlarmClockClickListener
01-10 13:12:00.049: D/WidgetUtils(732): setWeatherUpdateClickListener
01-10 13:12:00.059: D/WidgetUtils(732): setAccuWeatherCickListener
01-10 13:12:00.059: E/WidgetUtils(732): cityCode=cityId:167705
01-10 13:12:00.069: D/WidgetUtils(732): updateWeatherInfo
01-10 13:12:00.069: D/Utils(732): isDataOK
01-10 13:12:00.069: D/Utils(732): dataOverdue
01-10 13:12:00.069: D/PowerManagerService(199): releaseWakeLock flags=0x1 tag=AlarmManager
01-10 13:12:00.069: D/WidgetUtils(732): updateWeatherInfo temperature =3.3333333,time1357482579481,weatherDes=Mostly Cloudy,invalidDay=4
01-10 13:12:00.069: D/WidgetUtils(732): updateWeatherInfo weatherDayDataInfo =HighTemperature =3.3333333 LowTemperature =-0.5555556 WeatherIcon =7 TextShort=Cloudy and colder TextLong=Cloudy and colder with a rain and snow shower possible WindSpeed=5 WindDirection=W
01-10 13:12:00.069: D/WidgetUtils(732): updateCityDateTime 
01-10 13:12:00.069: D/WidgetUtils(732): getCurCityCalendar
01-10 13:12:00.069: D/WidgetUtils(732): builder=2013/01/10  Thursday,dayOfWeek=Thursday,dayFormat=2013/01/10
01-10 13:12:00.069: D/WidgetUtils(732): calender2ClockImgIdx
01-10 13:12:00.069: D/WidgetUtils(732): updateRefreshTime
01-10 13:12:00.069: D/Utils(732): isUpdating
01-10 13:12:00.069: D/Utils(732): isDataOK
01-10 13:12:00.069: D/Utils(732): dataOverdue
01-10 13:12:00.079: D/WidgetUtils(732): getUpdateTime relativeDay=4
01-10 13:12:01.029: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:07.029: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:13.039: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:19.039: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:25.049: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:31.049: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:37.059: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:43.069: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:49.069: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:55.069: E/CAM_FD(113): ...config thread select timeout...
01-10 13:12:59.999: D/PowerManagerService(199): acquireWakeLock flags=0x1 tag=AlarmManager
01-10 13:13:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver onReceive
01-10 13:13:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver actionandroid.intent.action.TIME_TICK
01-10 13:13:00.039: D/WeatherWidgetServerLite(732): WeatherWidgetReceiver msg.what=1001
01-10 13:13:00.039: I/WeatherMediumWidgetProvider(732): updateUI(Context context)
01-10 13:13:00.039: D/WeatherMediumWidgetProvider(732): updateUI(Context context, AppWidgetManager widgetManager, int[] appWidgetId)
01-10 13:13:00.039: D/WidgetUtils(732): setWeatherHomeClickListener
01-10 13:13:00.039: D/WidgetUtils(732): setWeatherHomeClickListener
01-10 13:13:00.049: D/WidgetUtils(732): setAlarmClockClickListener
01-10 13:13:00.059: D/WidgetUtils(732): setAlarmClockClickListener
01-10 13:13:00.059: D/WidgetUtils(732): setWeatherUpdateClickListener
01-10 13:13:00.059: D/WidgetUtils(732): setAccuWeatherCickListener
01-10 13:13:00.059: E/WidgetUtils(732): cityCode=cityId:167705
01-10 13:13:00.059: D/WidgetUtils(732): updateWeatherInfo
01-10 13:13:00.059: D/Utils(732): isDataOK
01-10 13:13:00.059: D/Utils(732): dataOverdue
01-10 13:13:00.059: D/PowerManagerService(199): releaseWakeLock flags=0x1 tag=AlarmManager
01-10 13:13:00.069: D/WidgetUtils(732): updateWeatherInfo temperature =3.3333333,time1357482579481,weatherDes=Mostly Cloudy,invalidDay=4
01-10 13:13:00.069: D/WidgetUtils(732): updateWeatherInfo weatherDayDataInfo =HighTemperature =3.3333333 LowTemperature =-0.5555556 WeatherIcon =7 TextShort=Cloudy and colder TextLong=Cloudy and colder with a rain and snow shower possible WindSpeed=5 WindDirection=W
01-10 13:13:00.069: D/WidgetUtils(732): updateCityDateTime 
01-10 13:13:00.069: D/WidgetUtils(732): getCurCityCalendar
01-10 13:13:00.069: D/WidgetUtils(732): builder=2013/01/10  Thursday,dayOfWeek=Thursday,dayFormat=2013/01/10
01-10 13:13:00.069: D/WidgetUtils(732): calender2ClockImgIdx
01-10 13:13:00.069: D/WidgetUtils(732): updateRefreshTime
01-10 13:13:00.069: D/Utils(732): isUpdating
01-10 13:13:00.069: D/Utils(732): isDataOK
01-10 13:13:00.069: D/Utils(732): dataOverdue
01-10 13:13:00.069: D/WidgetUtils(732): getUpdateTime relativeDay=4

2 个答案:

答案 0 :(得分:0)

试试这个..

如果您的相机挂在拍照上,您可以试试这个..

camera.setPreviewCallback(new PreviewCallback() {

        @Override
        public synchronized void onPreviewFrame(byte[] data, Camera arg1) {
            if (!mTakePicture) {
                CameraPreview.this.invalidate();
            } else {

                if (mTakePictureCallback != null && !mPictureTaken) {
                    int rgb[] = new int[previewSize.width*previewSize.height];
                    decodeYUV420SP(rgb, data, previewSize.width, previewSize.height);
                    Bitmap memoryImage = Bitmap.createBitmap(rgb, previewSize.width, previewSize.height, Bitmap.Config.ARGB_8888);
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    memoryImage.compress(CompressFormat.JPEG, 100, baos);
                    shutterSound();
                    setBackgroundDrawable(new BitmapDrawable(getContext().getResources(), memoryImage));
                    mTakePictureCallback.onPictureTaken(baos.toByteArray(), arg1);
                }
                mPictureTaken = true;
                camera.stopPreview();
            }
        }
    });

//否则你可能会这样做..

public class CamaraView extends Activity implements SurfaceHolder.Callback,
        OnClickListener {
    static final int FOTO_MODE = 0;
    private static final String TAG = "CameraTest";
    Camera mCamera;
    boolean mPreviewRunning = false;
    private Context mContext = this;


    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        Log.e(TAG, "onCreate");

        Bundle extras = getIntent().getExtras();


        getWindow().setFormat(PixelFormat.TRANSLUCENT);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.surface_camera);
        mSurfaceView = (SurfaceView) findViewById(R.id.surface_camera);
        mSurfaceView.setOnClickListener(this);
        mSurfaceHolder = mSurfaceView.getHolder();
        mSurfaceHolder.addCallback(this);
        mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
    }

    Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
        public void onPictureTaken(byte[] imageData, Camera c) {

            if (imageData != null) {

                Intent mIntent = new Intent();

                FileUtilities.StoreByteImage(mContext, imageData,
                         50, "ImageName");
                mCamera.startPreview();

                setResult(FOTO_MODE,mIntent);
                finish();


            }
        }
    };

    protected void onResume() {
        Log.e(TAG, "onResume");
        super.onResume();
    }

    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }

    protected void onStop() {
        Log.e(TAG, "onStop");
        super.onStop();
    }

    public void surfaceCreated(SurfaceHolder holder) {
        Log.e(TAG, "surfaceCreated");
        mCamera = Camera.open();

    }

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        Log.e(TAG, "surfaceChanged");

        // XXX stopPreview() will crash if preview is not running
        if (mPreviewRunning) {
            mCamera.stopPreview();
        }

        Camera.Parameters p = mCamera.getParameters();
        p.setPreviewSize(w, h);
        mCamera.setParameters(p);
        try {
            mCamera.setPreviewDisplay(holder);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        mCamera.startPreview();
        mPreviewRunning = true;
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        Log.e(TAG, "surfaceDestroyed");
        mCamera.stopPreview();
        mPreviewRunning = false;
        mCamera.release();
    }

    private SurfaceView mSurfaceView;
    private SurfaceHolder mSurfaceHolder;

    public void onClick(View arg0) {

        mCamera.takePicture(null, mPictureCallback, mPictureCallback);

    }

}

这是详细链接..

http://www.dzone.com/snippets/how-take-pictures-android

http://www.41post.com/3470/programming/android-retrieving-the-camera-preview-as-a-pixel-array谁在Ketai http://code.google.com/p/ketai/

找到了它

答案 1 :(得分:0)

事实证明,在Android 2.3中,您需要创建一个SurfaceView并使用StartPreview来拍摄照片。 Android文档显示了如何创建此SurfaceView,但它也表示您不需要“活动”来拍摄照片,并且它们的示例仅显示从活动中拍摄的照片。

我使用他们的示例代码创建了SurfaceView,但不必将其应用于FragmentLayout。

我个人认为Android文档存在不一致之处。一方面,他们告诉你,你不需要预览(对于Android 2.2和4.0来说似乎都是如此),但你显然需要2.3。