我拍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();
}