在模拟器中工作getSupportedFocusModes()为null

时间:2012-03-17 04:19:51

标签: android android-emulator android-camera

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();

为什么focusModesnull?当我在真实设备上启动应用程序时,一切正常,但是Emulator会抛出空指针异常。

0 个答案:

没有答案