麻烦在Android的Galaxy S3访问前置摄像头摄像头、麻烦、Galaxy、Android

2023-09-06 15:29:50 作者:不准偷偷亲我

我有一个小程序,我一直在使用前置摄像头。我一直在使用获得的前置摄像头的方式似乎在大多数手机上运行,​​但用户一直在报告的S3和其他各种新设备的麻烦。我一直访问前置摄像头的方式是像这样:

I have a small app I have been working on that uses the front camera. The way I have been obtaining use of the front camera seems to work on most phones, but users have been reporting trouble on the S3 and various other new devices. The way I have been accessing the front camera is like so:

// Find the ID of the front camera
        CameraInfo cameraInfo = new CameraInfo();
        for(int i = 0; i < numberOfCameras; i++) {
            Camera.getCameraInfo(i, cameraInfo);
            if(cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT) {
                defaultCameraId = i;
                mCameraFound = true;
            }
        }
        if(!mCameraFound) 
            displayDialog(8);

从一些错误的报告我已经添加到应用程序中,我注意到了S3居然找到了前置摄像头,但用户报告只显示黑屏?我只能够测试我有设备(GNEX和N7)上。我希望有人在这里可能有一些这方面的经验或可能够帮我解决这个问题。如果你想尝试应用了你的S3,检查下面的链接。先谢谢了。

From some of the error reporting I've added into the app, I've noticed the S3 actually finds the front camera, but users report it only shows a blank screen? I have only been able to test on the devices I have (GNex and N7). I was hoping someone here may have some experience with this or may be able to help me solve this issue. If you want to try the app out on your S3, check the link below. Thanks in advance.

https://play.google.com/store/应用程序/详细信息?ID = com.wckd_dev.mirror

编辑:我创建了包含用于preVIEW一个TextureView一个的MirrorView对象。该对象的MirrorView实现了SurfaceTextureListener。内onSurfaceTextureAvailable()方法,其中preVIEW被启动。我也创造了重新启动preVIEW应用已经从隐藏的回可见死后的方法。

I created a MirrorView object which contains a TextureView used for the preview. The MirrorView object implements a SurfaceTextureListener. Within the onSurfaceTextureAvailable() method is where the preview is started. I also created a method for restarting the preview after the app has gone from hidden back to visible.

所以,当应用程序首次启动这就是所谓的:

So this is called when the app is first started:

    @Override
    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
        try {
            if (mCamera != null) {

                Camera.Parameters parameters = mCamera.getParameters();
                parameters.setPreviewSize(mPreviewSize.height, mPreviewSize.width);
                requestLayout();

                mCamera.setParameters(parameters);
                mCamera.setPreviewTexture(surface);
                mCamera.startPreview();
            }
        } 
        catch(RuntimeException e) {
            // Log.e(TAG, "RuntimeException caused by setPreviewTexture()", exception);
        }
        catch (IOException e) {
            // Log.e(TAG, "IOException caused by setPreviewTexture()", exception);
        }
    }

重启preVIEW调用是相同的(但不同的)方法。从一些调试数据我一直在通过收集用户的,我注意到,该应用程序发现两款相机在S III并选择ID匹配CAMERA_FACING_FRONT。此外,这个问题似乎并没有在所有S III发生。我有谁拥有的反馈报告尽可能多的用户。从遇到此问题的用户身份的最新报告是一个AT&amp; T公司S III的用户。任何帮助将是AP preciated!

The restartPreview call is to an identical (but separate) method. From some of the debug data I've been collecting through users, I've noticed that the app finds two camera on the S III and selects the id matching CAMERA_FACING_FRONT. Also, this issue doesn't seem to be happening on all S III. I have users who have feedback reporting as much. The latest report from a user experiencing this issue was an AT&T S III user. Any help would be appreciated!

推荐答案

有一些洗脸的时候用S3今晚在遇到此问题,我的应用程序。这里发生了什么事情。该TextureView依赖于这应该在默认情况下2D硬件加速(从我的理解)在4.0以上版本的设备。这不是打开(我的应用程序至少)他的电话。此修复程序是在清单中添加一行(下应用程序)一样简单。

Got some face time with an S3 tonight that was experiencing this issue with my app. Here what was going on. The TextureView relies on 2d hardware acceleration which is supposed to on by default (from what I understood) on 4.0+ devices. It wasn't turning on (for my app at least) on his phone. The fix was as simple as adding a single line in the manifest (under application).

android:hardwareAcceleration = "true"