Android Camera Surface View
By : sindhuja
Date : March 29 2020, 07:55 AM
it should still fix some issue I am trying to create a surface view for a camera so it renders on the surface whenever is in the view of the camera. At the moment all I can see on my camera view is a black screen view. I have tried to look on Google and here but so far I haven't found what I am looking for. Anyone can suggest me some idea. , I have written a class that can help you. code :
public class Preview_can_work extends Activity {
private SurfaceView surface_view;
private Camera mCamera;
SurfaceHolder.Callback sh_ob = null;
SurfaceHolder surface_holder = null;
SurfaceHolder.Callback sh_callback = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
surface_view = new SurfaceView(getApplicationContext());
addContentView(surface_view, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
if (surface_holder == null) {
surface_holder = surface_view.getHolder();
}
sh_callback = my_callback();
surface_holder.addCallback(sh_callback);
}
SurfaceHolder.Callback my_callback() {
SurfaceHolder.Callback ob1 = new SurfaceHolder.Callback() {
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
mCamera = Camera.open();
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException exception) {
mCamera.release();
mCamera = null;
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
mCamera.startPreview();
}
};
return ob1;
}
}
<uses-permission android:name="android.permission.CAMERA"/>
Camera mCamera = Camera.open();
1. public void surfaceCreated(SurfaceHolder holder)
2. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
3. public void surfaceDestroyed(SurfaceHolder holder)
|
Android Camera surface-view camera recreated when i press back button on archos tablet on jellybean
By : user557610
Date : March 29 2020, 07:55 AM
|
Use Android Camera without surface View
By : Adrian
Date : March 29 2020, 07:55 AM
With these it helps As of API-Level 11 the SurfaceTexture was added. With it a SurfaceView is no longer needed. I tested the following code with my Samsung Galaxy S3 Neo.
|
UIImagePickerController camera cancel not working after browsed several view and opened camera?
By : Anil Kumar
Date : March 29 2020, 07:55 AM
This might help you I have some 15 to 20 views in app. One is for camera functionality. I have view in that which is set to UIImagePickerController to display camera. My problem is, when I open camera directly after app launches, everything works fine. I mean cancel, capture feature of default camera functionality. But suppose, if I browse all other than camera like map, webView,etc and atlast if I open camera, the cancel button is not working(capture button is working in all case).After I capture, controls like retake, use are showing successfully but those buttons also not accessible. , Use the following code
|
Android Camera: Attempt to invoke virtual method Android Camera Parameters on android.hardware.Camera.getParameters()' o
By : Chong Jia Sheng
Date : March 29 2020, 07:55 AM
With these it helps Check the app in your device Settings, if the required permissions are given or not. In my case, this was the reason for Exception, that I had not given permissions from the Settings. Hope it helps you.
|