Hi everybody,
I implemented a camera preview SurfaceView that is loosely based on
the camera preview example from the android apis demo.
On the same activity, i have some live sensor readings displayed.
I always had the idea that the activity is running very slow and i
previously got some image freezings when I switched between two
different activities that both displayed the camera preview. That was
when I was building for SDK 1.1 today I migrated my application to 1.5
and catched the following error message:
06-15 23:56:26.272: ERROR/AndroidRuntime(726):
java.lang.RuntimeException: Out of memory
06-15 23:56:26.272: ERROR/AndroidRuntime(726): at
android.hardware.Camera.native_setup(Native Method)
06-15 23:56:26.272: ERROR/AndroidRuntime(726): at
android.hardware.Camera.<init>(Camera.java:82)
06-15 23:56:26.272: ERROR/AndroidRuntime(726): at
android.hardware.Camera.open(Camera.java:64)
For clarity, I will post the code of my Preview class at the end.
Any idea what could be wrong?
Thanks a lot for your replies.
Patrick
package nl.uva.graffiti;
import android.content.Context;
import android.hardware.Camera;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public classPreview extends SurfaceView implements
SurfaceHolder.Callback{
SurfaceHolder mHolder;
Camera mCamera;
Context mContext;
public Preview(Context context) {
super(context);
init();
}
public Preview (Context context, AttributeSet attrs){
super(context, attrs);
mContext = context;
init();
}
public Preview(Context context, AttributeSet attrs, int defStyle){
super(context, attrs, defStyle);
init();
}
private void init(){
mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
public void surfaceCreated(SurfaceHolder holder) {
mCamera = Camera.open();
try {
mCamera.setPreviewDisplay(holder);
} catch (Exception exception) {
mCamera.release();
mCamera = null;
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
mCamera.stopPreview();
mCamera = null;
}
public void surfaceChanged(SurfaceHolder holder, int format, int
w, int h) {
Camera.Parameters parameters = mCamera.getParameters();
parameters.setPreviewSize(w, h);
mCamera.setParameters(parameters);
mCamera.startPreview();
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---