我正在开发一个不使用意图的android自定义相机应用程序(以避免获得android的内置相机功能)。我在我的应用程序中启用了自动对焦功能。我正在按下按键音量按钮拍照。我正在使用下面的代码来设置参数。
Camera.Parameters p = camera.getParameters();
camera.autoFocus(autoFocusCallback);
p.setFocusMode(Parameters.FOCUS_MODE_AUTO);
camera.setParameters(p1);
camera.takePicture(shutterCallback, rawCallback, jpgCallback);
void setHandler(Handler autoFocusHandler, int autoFocusMessage)
{
this.autoFocusHandler = autoFocusHandler;
this.autoFocusMessage = autoFocusMessage;
}
private AutoFocusCallback autoFocusCallback = new AutoFocusCallback()
{
private Object success;
@Override
public void onAutoFocus(boolean autoFocusSuccess, Camera camera)
{
if (autoFocusHandler != null)
{
Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success);
autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS);
autoFocusHandler = null;
}
else
{
}
}
};
但问题是,此代码仅适用于 LG 手机。并且在运行它后,我正在强制关闭所有其他手机。
错误日志看起来像这样
http://textuploader.com/?p=6&id=kOc9G
没有得到我要去的地方。请帮忙!谢谢!