There seems to be a problem on my Nexus 5 with KRT16M when taking a frame 
from the camera using android.hardware.Camera setOneShotPreviewCallback. 
 The camera preview goes dark and the frame saved is always dark.  After 
the call happens the preview stays dark.  This is a real problem since the 
saved frames are so dark they're pretty useless.  The code below 
demonstrates the problem and runs fine on every other device I've tried. 
 It seems like a legitimate problem.  Unless anyone has an answer I'm going 
to file a bug soon.

public class MainActivity extends Activity implements 
SurfaceTextureListener {

private Camera mCamera;
private TextureView mTextureView;

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

mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(this);

setContentView(mTextureView);

}

@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width,
int height) {
mCamera = Camera.open();

Camera.Size previewSize = mCamera.getParameters().getPreviewSize();
mTextureView.setLayoutParams(new FrameLayout.LayoutParams(
previewSize.width, previewSize.height, Gravity.CENTER));

try {
mCamera.setPreviewTexture(surface);
} catch (IOException t) {
}

mCamera.startPreview();

Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
mCamera.setOneShotPreviewCallback(new PreviewCallback() {
@Override
public void onPreviewFrame(byte[] data, Camera camera) {

}
});
}
}, 5000);
handler.postDelayed(new Runnable() {
@Override
public void run() {
mCamera.stopPreview(); 
}
}, 10000);
handler.postDelayed(new Runnable() {
@Override
public void run() {
mCamera.startPreview(); 
}
}, 15000);
}

@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width,
int height) {
}

@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
mCamera.stopPreview();
mCamera.release();
return true;
}

@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
}


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to