title: Android: Fail to connect to camera service at Camera.open();
body: <p>There are many questions similar to this, but none helped me:</p>
  
  <p>my manifest file is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.android.cameraapi"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk android:minSdkVersion="10" /&gt;
  
      &lt;uses-feature android:name="android.hardware.camera" /&gt;
      &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name" &gt;
          &lt;activity
              android:name=".CameraAPIActivity"
              android:label="@string/app_name"
              android:screenOrientation="landscape" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>my Activity class is:</p>
  
  <pre><code>public class CameraAPIActivity extends Activity {
      private Camera myCamera = null;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          if (checkCameraHardware(this)) {
  
              try {
  
                  myCamera = Camera.open();
              } catch (Exception e) {
  
                  //Here i get the Exception:  Failed to connect to camera service
              }
          }
  }
  
  private boolean checkCameraHardware(Context context) {
      if (context.getPackageManager().hasSystemFeature(
              PackageManager.FEATURE_CAMERA)) {
          // this device has a camera
          return true;
      } else {
          // no camera on this device
          return false;
      }
  }
  </code></pre>
  
  <p>i get the Exception at the line</p>
  
  <pre><code>myCamera = Camera.open();
  </code></pre>
  
  <p>Thank You</p>