I have a class (CameraView) that I use to take pictures within my app.
When running on a LG Nexus 4 (Android 4.2.1) there is no callback to onPictureTaken. Below is a basic example of how I am trying to achive this (i've obmitted all the initialisation stuff but it does happen). This code works and takes pictures on Galaxy Nexus (Android 4.2.1) and Galaxy S3 (Android 4.0.3) but not on a Nexus 4. I've tested for the callback onShutter() and all the onPictureTaken() ones too, raw, postview and jpeg but None of them are called when running on a Nexus 4.
EDIT:
In my first activity I have a button which starts the camera.
mImage = (Button) findViewById(R.id.takeimg);
mImage.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
startActivityForResult(new Intent(MyClass.this, CameraView.class), ACTION_ACTIVITY_PHOTO);
}
});
In my camera activity I have the following:
public class CameraView extends Activity implements PictureCallback{
private Camera mCamera;
private ImageButton mShutterBtn;
public void onCreate(Bundle savedInstanceState) {
mCamera = Camera.open();
mShutterBtn = (ImageButton) findViewById(R.id.shutter);
mShutterBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
mShutterBtn.setImageResource(R.drawable.shutter_pressed);
close_shutter();
}
});
}
protected void onResume() {
mCamera.startPreview();
}
private void close_shutter(){
mCamera.takePicture(null, null, this);
}
public void onPictureTaken(byte[] data, Camera camera) {
//save image...
setResult(RESULT_OK);
finish()
}
}
Below is the verbose LogCat log for what happens from the time the Activity starts, through attempting to take the image and then finishing the activity. I can't see anything in it that points me to an issue with my code. Any help will be apreciated.
01-29 12:44:39.997: W/CameraView(10936): onCreate
01-29 12:44:40.157: I/AwesomePlayer(165): setDataSource_l(URL suppressed)
01-29 12:44:40.197: I/AwesomePlayer(165): setDataSource_l(URL suppressed)
01-29 12:44:40.237: I/CameraClient(165): Opening camera 0
01-29 12:44:40.277: E/qcom_sensors_hal(590): hal_process_report_ind: Bad item quality: 11
01-29 12:44:40.307: E/mm-camera(195): sensor_load_chromatix: libchromatix_imx111_preview.so: 30
01-29 12:44:40.337: E/qcom_sensors_hal(590): hal_process_report_ind: Bad item quality: 11
01-29 12:44:40.418: E/mm-camera(195): vfe_ops_init: E
01-29 12:44:40.418: E/mm-camera(195): vfe_legacy_stats_buffer_init: AEC_STATS_BUFNUM
01-29 12:44:40.418: E/mm-camera(195): vfe_legacy_stats_buffer_init: AEC_STATS_BUFNUM
01-29 12:44:40.428: E/mm-camera(195): mctl_init_stats_proc_info: snap_max_line_cnt =30096
01-29 12:44:40.558: W/CameraView(10936): onResume
01-29 12:44:40.588: I/Choreographer(10936): Skipped 35 frames! The application may be doing too much work on its main thread.
01-29 12:44:40.738: E/QCameraHWI(165): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*): mPreviewWindow = 0x0x4004bc38, mStreamDisplay = 0x0x40132008
01-29 12:44:40.738: D/QCameraHWI(165): android::status_t android::QCameraHardwareInterface::startPreview(): start preview now
01-29 12:44:40.738: I/QCameraHWI(165): android::status_t android::QCameraHardwareInterface::startPreview2():Setting ZSL mode
01-29 12:44:40.748: E/mm-camera(195): config_proc_CAMERA_SET_INFORM_STARTPREVIEW
01-29 12:44:40.748: E/mm-camera(195): config_proc_CAMERA_SET_INFORM_STARTPREVIEW : AF_SET_INFORM_STARTPREVIEW!
01-29 12:44:40.748: E/mm-camera(195): config_update_stream_info Storing stream parameters for video inst 1 as : width = 640, height 480, format = 1 inst_handle = 810081 cid = 0
01-29 12:44:40.768: E/mm-camera(195): config_update_stream_info Storing stream parameters for video inst 3 as : width = 640, height 480, format = 1 inst_handle = 830083 cid = 0
01-29 12:44:40.768: E/mm-camera(195): config_update_stream_info Storing stream parameters for video inst 4 as : width = 512, height 384, format = 1 inst_handle = 840084 cid = 0
01-29 12:44:40.778: E/mm-camera(195): config_decide_vfe_outputs: Ports Used 3, Op mode 1
01-29 12:44:40.778: E/mm-camera(195): config_decide_vfe_outputs Current mode 0 Full size streaming : Disabled
01-29 12:44:40.778: E/mm-camera(195): config_decide_vfe_outputs: Primary: 640x480, extra_pad: 0x0, Fmt: 1, Type: 1, Path: 1
01-29 12:44:40.778: E/mm-camera(195): config_decide_vfe_outputs: Secondary: 640x480, extra_pad: 0x0, Fmt: 1, Type: 3, Path: 4
01-29 12:44:40.778: E/mm-camera(195): config_update_inst_handles Updated the inst handles as 810081, 830083, 0, 0
01-29 12:44:40.918: E/mm-camera(195): sensor_load_chromatix: libchromatix_imx111_zsl.so: 26
01-29 12:44:41.008: E/mm-camera(195): camif_client_set_params: camif has associated with obj mask 0x1
01-29 12:44:41.008: E/mm-camera(195): config_v2_CAMERA_START_common CAMIF_PARAMS_ADD_OBJ_ID failed -1
01-29 12:44:41.008: E/mm-camera(195): vfe_operation_config: format 3
01-29 12:44:41.008: E/mm-camera(195): vfe_operation_config:vfe_op_mode=5
01-29 12:44:41.008: E/mm-camera(195): Invalid ASD Set Params Type
01-29 12:44:41.008: E/mm-camera(195): vfe_set_bestshot: Bestshot mode not changed
01-29 12:44:41.038: E/mm-libcamera2(165): PROFILE HAL: stopPreview(): E: 1359463481.041744933
01-29 12:44:41.038: E/mm-camera(195): config_MSG_ID_STOP_ACK: streamon_mask is not clear. Should not call PP_Release_HW
01-29 12:44:41.148: E/mm-camera(195): config_proc_CAMERA_SET_PARM_AF_MODE Unlock CAF
01-29 12:44:41.148: E/QCameraHWI(165): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*): mPreviewWindow = 0x0x4004bc38, mStreamDisplay = 0x0x40132008
01-29 12:44:41.158: D/QCameraHWI(165): android::status_t android::QCameraHardwareInterface::startPreview(): start preview now
01-29 12:44:41.158: I/QCameraHWI(165): android::status_t android::QCameraHardwareInterface::startPreview2():Setting ZSL mode
01-29 12:44:41.158: E/mm-camera(195): config_proc_CAMERA_SET_INFORM_STARTPREVIEW
01-29 12:44:41.158: E/mm-camera(195): config_proc_CAMERA_SET_INFORM_STARTPREVIEW : AF_SET_INFORM_STARTPREVIEW!
01-29 12:44:41.158: E/mm-camera(195): config_update_stream_info Storing stream parameters for video inst 1 as : width = 768, height 432, format = 1 inst_handle = 810081 cid = 0
01-29 12:44:41.168: E/mm-camera(195): config_update_stream_info Storing stream parameters for video inst 3 as : width = 640, height 480, format = 1 inst_handle = 830083 cid = 0
01-29 12:44:41.168: E/mm-camera(195): config_update_stream_info Storing stream parameters for video inst 4 as : width = 512, height 384, format = 1 inst_handle = 840084 cid = 0
01-29 12:44:41.178: E/mm-camera(195): config_decide_vfe_outputs: Ports Used 3, Op mode 1
01-29 12:44:41.178: E/mm-camera(195): config_decide_vfe_outputs Current mode 5 Full size streaming : Disabled
01-29 12:44:41.178: E/mm-camera(195): config_decide_vfe_outputs: Primary: 768x432, extra_pad: 0x0, Fmt: 1, Type: 1, Path: 1
01-29 12:44:41.178: E/mm-camera(195): config_decide_vfe_outputs: Secondary: 640x480, extra_pad: 0x0, Fmt: 1, Type: 3, Path: 4
01-29 12:44:41.178: E/mm-camera(195): config_update_inst_handles Updated the inst handles as 810081, 830083, 0, 0
01-29 12:44:41.178: E/mm-camera(195): camif_client_set_params: camif has associated with obj mask 0x1
01-29 12:44:41.178: E/mm-camera(195): config_v2_CAMERA_START_common CAMIF_PARAMS_ADD_OBJ_ID failed -1
01-29 12:44:41.178: E/mm-camera(195): vfe_operation_config: format 3
01-29 12:44:41.178: E/mm-camera(195): vfe_operation_config:vfe_op_mode=5
01-29 12:44:41.228: I/Choreographer(10936): Skipped 33 frames! The application may be doing too much work on its main thread.
01-29 12:44:41.248: E/mm-libcamera2(165): PROFILE HAL: First preview frame received: 1359463481.257401883
01-29 12:44:41.248: E/BufferQueue(162): [SurfaceView] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=6 undequeudCount=0)
01-29 12:44:41.328: I/ActivityManager(590): Displayed uk.co.appogee.cfh_rds/.deliver.CameraView: +1s369ms
01-29 12:44:41.338: E/BufferQueue(162): [SurfaceView] dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=5 undequeudCount=1)
01-29 12:44:41.359: D/overlay(162): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED
01-29 12:44:41.629: D/overlay(162): FROM_STATE = OV_CLOSED TO_STATE = OV_2D_VIDEO_ON_PANEL
01-29 12:44:42.169: D/dalvikvm(10936): GC_EXPLICIT freed 563K, 22% free 11467K/14680K, paused 3ms+5ms, total 44ms
01-29 12:44:42.480: E/mm-camera(195): PROFILE set_parm_AF: : 1359463482.482367550
01-29 12:44:42.480: E/mm-camera(195): af_lg_caf_status 7, af_lg_caf_fv_status 0, first_af 0
01-29 12:44:42.480: E/mm-camera(195): NO ADDITIONAL af HERE!
01-29 12:44:43.060: D/dalvikvm(590): GC_EXPLICIT freed 842K, 31% free 25749K/37136K, paused 5ms+10ms, total 101ms
01-29 12:44:43.190: E/mm-camera(195): config_proc_CAMERA_SET_LG_CAF_LOCK : TAKE PICTURE!
01-29 12:44:43.271: E/mm-libcamera2(165): mm_camera_dispatch_buffered_frames: mframe 0x0, sframe = 0x0
01-29 12:44:43.871: D/dalvikvm(10936): GC_EXPLICIT freed 367K, 22% free 11534K/14680K, paused 3ms+5ms, total 37ms
01-29 12:44:44.722: D/dalvikvm(590): GC_EXPLICIT freed 437K, 31% free 25740K/37136K, paused 3ms+9ms, total 98ms
01-29 12:44:45.623: D/alsa_ucm(165): snd_use_case_set(): uc_mgr 0x41fa22a0 identifier _verb value Inactive
01-29 12:44:45.623: D/alsa_ucm(165): Set mixer controls for HiFi Lowlatency enable 0
01-29 12:44:45.623: D/alsa_ucm(165): snd_use_case_set(): uc_mgr 0x41fa22a0 identifier _disdev value Speaker
01-29 12:44:45.623: D/alsa_ucm(165): Set mixer controls for Speaker enable 0
01-29 12:44:45.653: I/wpa_supplicant(765): wlan0: Authentication with 00:04:96:2a:7a:59 timed out.
01-29 12:44:45.693: D/dalvikvm(10936): GC_EXPLICIT freed 366K, 22% free 11536K/14680K, paused 7ms+11ms, total 77ms
01-29 12:44:45.983: W/ActivityManager(590): Activity idle timeout for ActivityRecord{42aab158 u0 uk.co.appogee.cfh_rds/.deliver.Deliver}
01-29 12:44:46.594: D/dalvikvm(590): GC_EXPLICIT freed 433K, 31% free 25737K/37136K, paused 6ms+10ms, total 108ms
01-29 12:44:47.275: I/wpa_supplicant(765): wlan0: Trying to associate with 00:04:96:2a:7a:2a (SSID='APPOGEE' freq=2432 MHz)
01-29 12:44:47.355: I/wpa_supplicant(765): wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:04:96:2a:7a:2a status_code=1
01-29 12:44:47.375: D/dalvikvm(982): GC_CONCURRENT freed 366K, 6% free 9695K/10256K, paused 5ms+3ms, total 34ms
01-29 12:44:47.665: D/dalvikvm(10936): GC_EXPLICIT freed 369K, 22% free 11539K/14680K, paused 2ms+7ms, total 51ms
01-29 12:44:48.466: D/dalvikvm(590): GC_EXPLICIT freed 491K, 31% free 25734K/37136K, paused 3ms+11ms, total 93ms
01-29 12:44:48.726: D/AudioStreamOutALSA(165): mHandle->useCase: HiFi Lowlatency
01-29 12:44:48.726: D/ALSAModule(165): s_route: devices 0x2 in mode 0
01-29 12:44:48.726: D/ALSAModule(165): switchDevice: device 2 mode:0
01-29 12:44:48.726: D/ALSAModule(165): No valid input device: 0
01-29 12:44:48.726: D/ALSAModule(165): switchDevice,rxDev:Speaker, txDev:(null), curRxDev:Speaker, curTxDev:None
01-29 12:44:48.726: D/alsa_ucm(165): snd_use_case_set(): uc_mgr 0x41fa22a0 identifier _enadev value Speaker
01-29 12:44:48.726: D/ALSAModule(165): switchDevice: curTxUCMDevivce None curRxDevDevice Speaker
01-29 12:44:48.726: D/alsa_ucm(165): snd_use_case_set(): uc_mgr 0x41fa22a0 identifier _verb value HiFi Lowlatency
01-29 12:44:48.726: D/alsa_ucm(165): Set mixer controls for Speaker enable 1
01-29 12:44:48.726: D/ACDB-LOADER(165): ACDB -> send_afe_cal
01-29 12:44:48.726: D/alsa_ucm(165): Set mixer controls for HiFi Lowlatency enable 1
01-29 12:44:48.726: D/ALSAModule(165): Device value returned is hw:0,14
01-29 12:44:48.736: D/ALSAModule(165): setHardwareParams: reqBuffSize 1024 channels 2 sampleRate 48000
01-29 12:44:48.736: D/ALSAModule(165): setHardwareParams: buffer_size 2048, period_size 1024, period_cnt 2
01-29 12:44:48.766: W/CameraView(10936): onPause
01-29 12:44:48.766: E/mm-libcamera2(165): PROFILE HAL: stopPreview(): E: 1359463488.771425995
01-29 12:44:48.766: E/mm-camera(195): config_MSG_ID_STOP_ACK: streamon_mask is not clear. Should not call PP_Release_HW
01-29 12:44:48.766: E/mm-libcamera2(165): PROFILE HAL: stopPreview(): E: 1359463488.778537241
01-29 12:44:48.766: E/QCameraHWI(165): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*):Received Setting NULL preview window
01-29 12:44:48.766: E/QCameraHWI(165): android::status_t android::QCameraHardwareInterface::setPreviewWindow(preview_stream_ops_t*): mPreviewWindow = 0x0x0, mStreamDisplay = 0x0x40132008
01-29 12:44:48.766: W/QCameraHWI_Preview(165): Setting NULL preview window
01-29 12:44:48.776: I/CameraClient(165): Destroying camera 0
01-29 12:44:48.776: E/mm-camera(195): config_shutdown_pp Camera not in streaming mode. Returning.
01-29 12:44:48.776: E/mm-camera(195): vfe_ops_deinit: E
01-29 12:44:48.796: E/qcom_sensors_hal(590): hal_process_report_ind: Bad item quality: 11
01-29 12:44:48.846: W/AudioFlinger(165): session id 160 not found for pid 165
01-29 12:44:48.846: W/AudioFlinger(165): session id 161 not found for pid 165
01-29 12:44:48.857: E/qcom_sensors_hal(590): hal_process_report_ind: Bad item quality: 11
01-29 12:44:49.087: D/overlay(162): FROM_STATE = OV_2D_VIDEO_ON_PANEL TO_STATE = OV_CLOSED
01-29 12:44:49.347: D/overlay(162): FROM_STATE = OV_CLOSED TO_STATE = OV_BYPASS_3_LAYER
01-29 12:44:49.948: W/ActivityManager(590): Launch timeout has expired, giving up wake lock!
01-29 12:44:49.958: W/ActivityManager(590): Activity idle timeout for ActivityRecord{42a30e78 u0 uk.co.appogee.cfh_rds/.deliver.CameraView}
01-29 12:44:50.118: D/dalvikvm(10936): GC_EXPLICIT freed 372K, 22% free 11548K/14680K, paused 2ms+6ms, total 41ms
01-29 12:44:50.859: D/dalvikvm(590): GC_EXPLICIT freed 835K, 31% free 25730K/37136K, paused 5ms+10ms, total 118ms
01-29 12:44:51.209: E/DhcpStateMachine(590): DHCP failed on wlan0: Timed out waiting for DHCP to finish
01-29 12:44:51.800: D/dalvikvm(10936): GC_EXPLICIT freed 542K, 23% free 11371K/14680K, paused 2ms+5ms, total 38ms
01-29 12:44:51.960: D/alsa_ucm(165): snd_use_case_set(): uc_mgr 0x41fa22a0 identifier _verb value Inactive
01-29 12:44:51.960: D/alsa_ucm(165): Set mixer controls for HiFi Lowlatency enable 0
01-29 12:44:51.960: D/alsa_ucm(165): snd_use_case_set(): uc_mgr 0x41fa22a0 identifier _disdev value Speaker
01-29 12:44:51.960: D/alsa_ucm(165): Set mixer controls for Speaker enable 0
01-29 12:44:52.360: D/overlay(162): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED
01-29 12:44:52.410: D/dalvikvm(590): GC_EXPLICIT freed 418K, 31% free 25728K/37136K, paused 9ms+10ms, total 128ms
01-29 12:44:53.722: D/dalvikvm(10936): GC_EXPLICIT freed 362K, 23% free 11371K/14680K, paused 2ms+5ms, total 37ms
01-29 12:44:54.262: D/dalvikvm(590): GC_EXPLICIT freed 420K, 31% free 25728K/37136K, paused 3ms+9ms, total 94ms
01-29 12:44:55.544: D/dalvikvm(10936): GC_EXPLICIT freed 367K, 23% free 11373K/14680K, paused 4ms+5ms, total 47ms
01-29 12:44:56.014: D/dalvikvm(590): GC_EXPLICIT freed 418K, 31% free 25728K/37136K, paused 3ms+10ms, total 93ms
01-29 12:44:57.195: D/dalvikvm(10936): GC_EXPLICIT freed 365K, 23% free 11373K/14680K, paused 2ms+5ms, total 36ms
01-29 12:44:57.275: I/wpa_supplicant(765): wlan0: Authentication with 00:04:96:2a:7a:2a timed out.
01-29 12:44:57.756: D/dalvikvm(590): GC_EXPLICIT freed 429K, 31% free 25730K/37136K, paused 4ms+9ms, total 107ms
01-29 12:44:58.857: W/ActivityManager(590): Activity idle timeout for ActivityRecord{42aab158 u0 uk.co.appogee.cfh_rds/.deliver.Deliver}
01-29 12:44:58.907: D/overlay(162): FROM_STATE = OV_CLOSED TO_STATE = OV_BYPASS_3_LAYER
01-29 12:44:58.957: I/wpa_supplicant(765): wlan0: Trying to associate with 00:04:96:2a:7a:59 (SSID='APPOGEE' freq=2452 MHz)
01-29 12:44:59.027: D/dalvikvm(10936): GC_EXPLICIT freed 365K, 23% free 11374K/14680K, paused 5ms+7ms, total 66ms
01-29 12:44:59.027: I/wpa_supplicant(765): wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:04:96:2a:7a:59 status_code=1
01-29 12:44:59.468: D/dalvikvm(590): GC_EXPLICIT freed 462K, 31% free 25737K/37136K, paused 3ms+11ms, total 96ms
01-29 12:45:00.929: D/dalvikvm(10936): GC_EXPLICIT freed 357K, 23% free 11374K/14680K, paused 3ms+5ms, total 36ms
01-29 12:45:01.270: D/dalvikvm(590): GC_EXPLICIT freed 443K, 31% free 25734K/37136K, paused 4ms+10ms, total 94ms
01-29 12:45:01.920: D/overlay(162): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED
01-29 12:45:02.641: D/dalvikvm(10936): GC_EXPLICIT freed 359K, 23% free 11375K/14680K, paused 2ms+6ms, total 39ms
01-29 12:45:02.932: D/dalvikvm(590): GC_EXPLICIT freed 417K, 31% free 25733K/37136K, paused 3ms+9ms, total 113ms
01-29 12:45:04.443: D/dalvikvm(10936): GC_EXPLICIT freed 363K, 23% free 11376K/14680K, paused 2ms+5ms, total 36ms
01-29 12:45:04.643: D/dalvikvm(590): GC_EXPLICIT freed 416K, 31% free 25733K/37136K, paused 3ms+10ms, total 98ms
01-29 12:45:05.274: D/overlay(162): FROM_STATE = OV_CLOSED TO_STATE = OV_BYPASS_3_LAYER
01-29 12:45:05.965: D/dalvikvm(10936): GC_EXPLICIT freed 362K, 23% free 11377K/14680K, paused 2ms+4ms, total 39ms
01-29 12:45:06.095: D/dalvikvm(590): GC_EXPLICIT freed 422K, 31% free 25733K/37136K, paused 7ms+10ms, total 127ms
01-29 12:45:06.936: D/overlay(162): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED
01-29 12:45:06.936: I/InputReader(590): Reconfiguring input devices. changes=0x00000004
01-29 12:45:06.936: I/InputReader(590): Device reconfigured: id=6, name='touch_dev', size 768x1280, orientation 3, mode 1, display id 0
01-29 12:45:06.936: I/ActivityManager(590): Config changed: {1.3 234mcc20mnc en_GB ldltr sw384dp w598dp h359dp 320dpi nrml land finger -keyb/v/h -nav/h s.23}