Android 2.3.3仿真器无法识别相机中的对焦模式。
public class LayerCounterActivity extends Activity {
private Camera mCamera;
private CameraPreview mPreview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
if (checkCameraHardware(getBaseContext())){
Toast.makeText(this, "Camera OK!", Toast.LENGTH_LONG).show();
mCamera=getCameraInstance();
if (mCamera==null){
Toast.makeText(this, "Camera not ready!", Toast.LENGTH_LONG).show();
}
else {
Camera.Parameters params = mCamera.getParameters();
List<String> focusModes = params.getSupportedFocusModes();
为什么focusModes
是null
?当我在真实设备上启动应用程序时,一切正常,但是Emulator会抛出空指针异常。