【问题标题】:Crash camera after 3 shots3 次拍摄后相机崩溃
【发布时间】:2012-12-26 14:26:14
【问题描述】:

在我拍摄 3 张照片后,相机停止响应(崩溃)。如果我尝试重新启动应用程序相机状态 == 锁定并且默认相机也被锁定。 示例代码:

private Runnable SimpleShot=new Runnable()
{
    @Override
    public void run()
    {
        int i=0;
        while (i<7)
        {
            simpleShot();
            try
            {
                Thread.sleep(1500);
            } catch (InterruptedException e)
            {
                e.printStackTrace();
            }
            i++;
        }

    }
};

private void simpleShot()
{
    //System.gc();
    camera.takePicture(shutterCallback,rawCallback, this);
}

如果我不使用线程相机在第 3 次拍摄后也没有响应。请帮忙。 在onPictureTaken的end方法中,我调用camera.startPreview();

LogCat http://pastebin.com/qDcthyNe

    @Override
public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera)
{
    if(Utils.isSDAval() && Utils.PrepareAppFolder())
    {
        String path = Utils.APP_FOLDER+"/"+"APP"+"_"+Utils.getDate()+ CameraPrefsActivity.EXT_PIC;
        try
        {
            FileOutputStream os = new FileOutputStream(path);
            os.write(paramArrayOfByte);
            os.close();

        } catch (Exception e)
        {
            Utils.ShowInfo(this,getString(R.string.app_error_io));
            e.printStackTrace();
        }

        Utils.ShowInfo(this,getString(R.string.app_shot_ok));
        SharedPreferences main_pref = PreferenceManager.getDefaultSharedPreferences(this);
        String string_format = main_pref.getString("pref_preview_time","0");

        int timer_val = -1;
        if(string_format.contains("0"))
        {
            timer_val = -1;
        }

        if(string_format.contains("1"))
        {
            timer_val = 1;
        }

        if(string_format.contains("3"))
        {
            timer_val = 3;
        }

        if(string_format.contains("5"))
        {
            timer_val = 5;
        }

        if(string_format.contains("10"))
        {
            timer_val = 10;
        }

        if(timer_val > 0)
        {
            Intent intent = new Intent(this,CameraPreview.class);
            CameraPreview.setupActivity(path,timer_val);
            startActivity(intent);
        }

    }
    else
    {
        Utils.ShowInfo(this,getString(R.string.app_error_sd));
    }

    paramCamera.startPreview();
}

【问题讨论】:

  • 请在此处发布您的 logcat...
  • 堆栈跟踪在哪里? camera 是什么? takePicture 是什么?等等……
  • 相机是相机相机
  • 你是在模拟器上运行它吗?如果是这样,它也会发生在真实设备上吗?

标签: android crash camera


【解决方案1】:

This 的家伙也有同样的问题,显然是模拟器,尝试在适合他的真实设备上运行它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 2015-01-03
    • 2017-06-27
    • 1970-01-01
    相关资源
    最近更新 更多