takepicture挂在Android 2.3.3上

takepicture挂在Android 2.3.3上,第1张

概述我有一些在 Android 2.1和2.2中可以使用的照片代码. 但这些代码破解在Android 2.3. 在花费时间解决这个无效的问题之后,我想在这里寻求帮助. 我的代码流程如下图所示: 创建一个类Camlayer扩展了SurfaceView public class CamLayer extends SurfaceView implements SurfaceHolder.Callback { 我有一些在 Android 2.1和2.2中可以使用的照片代码.
但这些代码破解在AndroID 2.3.
在花费时间解决这个无效的问题之后,我想在这里寻求帮助.

我的代码流程如下图所示:

创建一个类Camlayer扩展了SurfaceVIEw

public class CamLayer extends SurfaceVIEw implements SurfaceHolder.Callback {    private voID init(Context context){        // Install a SurfaceHolder.Callback so we get notifIEd when the        // underlying surface is created and destroyed.        mHolder = getHolder();        mHolder.addCallback(this);        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);        mCamera = Camera.open();    }    public CamLayer(Context context) {        super(context);        init(context);    }    public CamLayer(Context context,AttributeSet attrs) {        super(context,attrs);        init(context);    }    public voID surfaceChanged(SurfaceHolder holder,int format,int w,int h) {        Log.i(TAG+".surfaceChanged","being called!");        Log.i(TAG+".surfaceChanged","w="+w);         Log.i(TAG+".surfaceChanged","h="+h);        if (isPrevIEwRunning) {            mCamera.stopPrevIEw();        }        try {            mCamera.setPrevIEwdisplay(holder);            mCamera.setPrevIEwCallback(mPrevIEwCallback);        } catch (IOException e) {            Log.e(TAG+".surfaceCreated","mCamera.setPrevIEwdisplay(holder);");        }        Camera.Parameters p = mCamera.getParameters();          setoptimalSize(p,w,h,SIZEOFPREVIEW);        setoptimalSize(p,SIZEOFPICTURE);        mCamera.setParameters(p);        mCamera.startPrevIEw();        isPrevIEwRunning = true;    }    public voID takePicture(){        Log.i(TAG+".takePicture","being called!");        mCamera.takePicture(null,null,mPictureCallback);        Log.i(TAG+".takePicture","call ended!");    }}

CamLayer.takePicture()将被外部类调用来启动.

问题是在AndroID 2.3.3,takePicture将挂起,所以找到一个ANR问题.在/data/anr/traces.txt中,找到以下内容.如你所见,native_takePicture永远不会返回.

DALVIK螺纹:

(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)"main" prio=5 tID=1 NATIVE  | group="main" sCount=1 dsCount=0 obj=0x40022170 self=0xce68  | sysTID=2411 nice=0 sched=0/0 cgrp=default handle=-1345006464  at androID.harDWare.Camera.native_takePicture(Native Method)  at androID.harDWare.Camera.takePicture(Camera.java:746)  at androID.harDWare.Camera.takePicture(Camera.java:710)  at oms.cj.tube.camera.CamLayer.takePicture(CamLayer.java:256)  at oms.cj.tube.camera.definecolor.takePicture(definecolor.java:61)  at oms.cj.tube.camera.definecolor.onKeyUp(definecolor.java:71)  at androID.vIEw.KeyEvent.dispatch(KeyEvent.java:1280)  at androID.app.Activity.dispatchKeyEvent(Activity.java:2078)  at com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.dispatchKeyEvent(PhoneWindow.java:1666)  at androID.vIEw.VIEwRoot.deliverKeyEventToVIEwHIErarchy(VIEwRoot.java:2571)  at androID.vIEw.VIEwRoot.handleFinishedEvent(VIEwRoot.java:2546)  at androID.vIEw.VIEwRoot.handleMessage(VIEwRoot.java:1878)  at androID.os.Handler.dispatchMessage(Handler.java:99)  at androID.os.Looper.loop(Looper.java:123)  at androID.app.ActivityThread.main(ActivityThread.java:3691)  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:841)  at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:599)  at dalvik.system.NativeStart.main(Native Method)

有没有人有同样的问题?知道如何解决?

解决方法 我也观察到mCamera.takePicture(null,handler)来冻结.我尝试清除预览处理程序:mCamera.setPrevIEwCallback(null)在调用takePicture()之前,它现在工作. 总结

以上是内存溢出为你收集整理的takepicture挂在Android 2.3.3上全部内容,希望文章能够帮你解决takepicture挂在Android 2.3.3上所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1133147.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存