【问题标题】:Nexus 7 2013 with Android L camera issue: onPreviewFrame not calledNexus 7 2013 与 Android L 相机问题:未调用 onPreviewFrame
【发布时间】:2014-10-16 13:45:23
【问题描述】:

我有非常基本的相机初始化代码,可以让我在 Acer A500 (Android 3.1) 和 Ainol Novo 9 (Android 4.1.1) 上预览。我刚刚购买了 Nexus 7 2013,在上面安装了 Android L 预览版,发现我的相机相关代码不再有效。摄像头初始化成功,没有抛出异常,包括startPReview()调用。然而,onPreviewFrame 根本没有被调用。可能是什么原因?

可能是因为我只有一个没有在任何地方显示的虚拟 SurfaceView?

private SurfaceView   m_surfaceView = new SurfaceView(CameraTestApplication.instance().getApplicationContext());
private SurfaceHolder m_surfaceHolder = m_surfaceView.getHolder();

void initCamera()
{
   m_openedCamera = Camera.open(0);
   ...
   m_openedCamera.setPreviewDisplay(m_surfaceHolder);
   m_openedCamera.setPreviewCallback(this);
   openedCamera.startPreview();
   ...
}

【问题讨论】:

  • Android L 还没有正式发布对吧?我认为在正式发布之前,您通常不能依赖它的全部功能。我知道我之前在使用最新版本和蓝牙时遇到过问题。
  • @JaySnayder:这是一种可能性。
  • @JaySnayder:刚刚试用了标准的 Android 相机应用。它有效。

标签: android camera android-camera android-5.0-lollipop


【解决方案1】:

解决了这个问题。事实上,这与我的人工SurfaceView 有关——我所做的还不够好。但是,这是可行的:

private SurfaceTexture m_previewTexture = new SurfaceTexture(8743);


void initCamera()
{
   m_openedCamera = Camera.open(0);
   ...
   m_openedCamera.setPreviewTexture(m_previewTexture);
   m_openedCamera.setPreviewCallback(this);
   openedCamera.startPreview();
   ...
}

【讨论】:

    猜你喜欢
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多