Hi,

I have made two versions of my desktop game on android using andengine. One
uses a normal image background and the other has augmented reality as the
background.

The links to both the games are:

https://market.android.com/details?id=com.raghavsood.speedball
https://market.android.com/details?id=com.raghavsood.speedballar

One common problem in both the games is that sometimes the moving ball
disappears. This in itself does not cause a crash or anything like that but
spoils the game as the ball is kind of the point.

The next few problems are related only to the augmented reality one (link 2)

1) When the game is started sometimes it displays the ACRA toast saying my
app has crashed but then continues straight on and opens the game which
works fine.

2) Sometimes the game crashes on pressing the back button, opening it after
pressing the home button.

The two stacktraces below appear in both the problems.

java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.native_setup(Native Method)
at android.hardware.Camera.<init>(Camera.java:264)
at android.hardware.Camera.open(Camera.java:239)
at
com.raghavsood.speedballar.CameraPreviewSurfaceView.surfaceCreated(CameraPreviewSurfaceView.java:45)
at android.view.SurfaceView.updateWindow(SurfaceView.java:552)
at android.view.SurfaceView.dispatchDraw(SurfaceView.java:350)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1874)
at android.view.ViewRoot.draw(ViewRoot.java:1524)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1260)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1861)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3729)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
at dalvik.system.NativeStart.main(Native Method)

And

java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:914)
at
com.raghavsood.speedballar.CameraPreviewSurfaceView.surfaceChanged(CameraPreviewSurfaceView.java:62)
at android.view.SurfaceView.updateWindow(SurfaceView.java:549)
at android.view.SurfaceView.dispatchDraw(SurfaceView.java:348)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6883)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1862)
at android.view.ViewRoot.draw(ViewRoot.java:1522)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1258)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

CameraPreviewSurfaceView.java reads (Lines 62 and 45 from the above
stacktraces are in bold.):

package com.raghavsood.speedballar;

import java.io.IOException;

import org.anddev.andengine.util.Debug;

import android.content.Context;
import android.hardware.Camera;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

class CameraPreviewSurfaceView extends SurfaceView implements
SurfaceHolder.Callback {

        private final SurfaceHolder mSurfaceHolder;
        private Camera mCamera;

        public CameraPreviewSurfaceView(final Context pContext) {
                super(pContext);

                this.mSurfaceHolder = this.getHolder();
                this.mSurfaceHolder.addCallback(this);

this.mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        }

        public void surfaceCreated(final SurfaceHolder pSurfaceHolder) {
*                this.mCamera = Camera.open();*
                try {
                        this.mCamera.setPreviewDisplay(pSurfaceHolder);
                } catch (IOException e) {
                        Debug.e("Error in Camera.setPreviewDisplay", e);
                }
        }

        public void surfaceDestroyed(final SurfaceHolder pSurfaceHolder) {
                this.mCamera.stopPreview();
                this.mCamera.release();
                this.mCamera = null;
        }

        public void surfaceChanged(final SurfaceHolder pSurfaceHolder, final
int pPixelFormat, final int pWidth, final int pHeight) {
                final Camera.Parameters parameters =
this.mCamera.getParameters();
                parameters.setPreviewSize(pWidth, pHeight);
*                this.mCamera.setParameters(parameters);*
                this.mCamera.startPreview();
        }
}

I have removed extra white lines so if you count the lines it will be off.

Any suggestions on resolving these problems?

Thanks

-- 
Raghav Sood
http://www.raghavsood.com/
http://wiki.androidappcheck.com/
http://www.telstop.tel/
https://market.android.com/developer?pub=Appaholics

-- 
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

Reply via email to