title: Getting Camera error in Zxing Barcode Application
body: <p>I am trying to use Zxing Library for developing a barcode scanner.</p>
  
  <p>My activity is as follows:  </p>
  
  <pre><code>public class Scanner extends Activity {  
  
      private static final String PACKAGE = "com.test.scan";  
      private static final String SCANNER = "com.google.zxing.client.android.SCAN";  
      private static final String SCAN_FORMATS = "UPC_A,UPC_E,EAN_8,EAN_13,CODE_39,CODE_93,CODE_128";  
      private static final String SCAN_MODE = "QR_CODE_MODE";  
      public static final int REQUEST_CODE = 1;  
  
      @Override  
      public void onCreate(Bundle icicle) {  
          super.onCreate(icicle);  
  
          setContentView(R.layout.main);  
  
           Button ok;  
           ok = (Button) findViewById(R.id.b1);  
           ok.setOnClickListener(new View.OnClickListener() {  
  
               public void onClick(View v) {  
  
                  Intent scanIntent = new Intent(SCANNER);  
                  scanIntent.setPackage(PACKAGE);  
                  scanIntent.addCategory(Intent.CATEGORY_DEFAULT);  
                  scanIntent.putExtra("SCAN_FORMATS", SCAN_FORMATS);  
                  scanIntent.putExtra("SCAN_MODE", SCAN_MODE);  
                  try {  
                      startActivityForResult(scanIntent, REQUEST_CODE);  
                  } catch (ActivityNotFoundException e) {  
                       // TODO: Exception handling  
                  }  
              }  
  
          });  
       }
  </code></pre>
  
  <p>Also manifest file:  </p>
  
  <pre><code>    &lt;activity android:name=".Scanner"
              android:screenOrientation="landscape"   android:configChanges="orientation|keyboardHidden"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:windowSoftInputMode="stateAlwaysHidden"&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;activity android:name="com.google.zxing.client.android.CaptureActivity"
                  android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"  
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                  android:windowSoftInputMode="stateAlwaysHidden"&gt;
                  &lt;intent-filter&gt;
                      &lt;action     android:name="com.google.zxing.client.android.SCAN" /&gt;
                      &lt;category    android:name="android.intent.category.DEFAULT" /&gt;
                  &lt;/intent-filter&gt;
              &lt;/activity&gt;
              &lt;activity android:name="com.google.zxing.client.android.PreferencesActivity"
                  android:label="@string/preferences_name"&gt;
              &lt;/activity&gt;
              &lt;activity android:name="com.google.zxing.client.android.HelpActivity"
                  android:screenOrientation="user"&gt;
                  &lt;intent-filter&gt;
                      &lt;action android:name="android.intent.action.VIEW" /&gt;
                      &lt;category android:name="android.intent.category.DEFAULT" /&gt;
                  &lt;/intent-filter&gt;
              &lt;/activity&gt;
              &lt;activity android:name="com.google.zxing.client.android.share.ShareActivity"
                  android:label="@string/share_name" android:screenOrientation="user"
                  android:theme="@android:style/Theme.Light"&gt;
                  &lt;intent-filter&gt;
                      &lt;action android:name="com.google.zxing.client.android.SHARE" /&gt;
                      &lt;category android:name="android.intent.category.DEFAULT" /&gt;
                  &lt;/intent-filter&gt;
              &lt;/activity&gt;
      &lt;uses-permission android:name="android.permission.CAMERA"
  </code></pre>
  
  <p>But I am getting the following error:       </p>
  
  <p>"Sorry, the Android camera encountered a problem. You may need to restart the device".</p>
  
  <p>I have followed few blogs. </p>
  
  <p>Log:  </p>
  
  <pre><code>   Unexpected error initializating camera  
      01-27 10:40:48.281: WARN/CaptureActivity(1007): java.lang.RuntimeException: Fail to connect to camera service  
      01-27 10:40:48.281: WARN/CaptureActivity(1007):     at android.hardware.Camera.native_setup(Native Method)  
      01-27 10:40:48.281: WARN/CaptureActivity(1007):     at android.hardware.Camera.&lt;init&gt;(Camera.java:185)  
      01-27 10:40:48.281: WARN/CaptureActivity(1007):     at android.hardware.Camera.open(Camera.java:165)
     01-27 10:40:48.281: WARN/CaptureActivity(1007):     at com.google.zxing.client.android.camera.CameraManager.openDriver(CameraManager.java:126)
      01-27 10:40:48.281: WARN/CaptureActivity(1007):     at com.google.zxing.client.android.CaptureActivity.initCamera(CaptureActivity.java:606)  
      01-27 10:40:48.281: WARN/CaptureActivity(1007):     at com.google.zxing.client.android.CaptureActivity.surfaceCreated(CaptureActivity.java:346)   
      01-27 10:40:48.281: WARN/CaptureActivity(1007):     at android.view.SurfaceView.updateWindow(SurfaceView.java:532)  
      01-27 10:40:48.281: WARN/CaptureActivity(1007):     at android.view.SurfaceView.dispatchDraw(SurfaceView.java:339) 
  </code></pre>