title: Xamarin ZXing initialization error and missing permission
body: <p>I have a Xamarin.Forms project which needs a QR code scanner. I decided to use the ZXing library.
  The installation worked fine and I have created a DependencyService interface in the forms project so I can use the Android/iOS implementation in it. I have got the description for this from here:
  <a href="http://blog.thomaslebrun.net/2014/09/xamarin-scanning-qrcode-in-a-xamarin-forms-application/#.VcMrTPlNjkc" rel="nofollow">http://blog.thomaslebrun.net/2014/09/xamarin-scanning-qrcode-in-a-xamarin-forms-application/#.VcMrTPlNjkc</a></p>
  
  <p>The problem I have is that there is no constructor that takes one argument. Only one which takes zero arguments.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>[assembly: Dependency(typeof(QrCodeScanningService))]
  namespace my.project.Droid.DependencyServiceImplementations
  {
      public class QrCodeScanningService : IQrCodeScanningService
      {
          public async Task&lt;string&gt; ScanAsync()
          {
              var scanner = new ZXing.Mobile.MobileBarcodeScanner(Application.Context); 
      // error: 'ZXing.Mobile.MobileBarcodeScanner' does not contain a constructor that takes 1 arguments
  
              var scanResults = await scanner.Scan();
  
              return scanResults.Text;
          }
      }
  }
  </code></pre>
  
  <p>The official example of ZXing uses
  MobileBarcodeScanner.Initialize(Application);
  But here in my application the compiler says:</p>
  
  <pre><code>'Android.App.Application' is a 'type' but is used like a 'variable'
  </code></pre>
  
  <p>The library seems to work so far without initializing and passing the context but I don't think it is a good idea to use it this way.</p>
  
  <p>Further it crashes when putting the app into the background and getting it back to the foreground with the following exception:</p>
  
  <pre><code>[MonoDroid] UNHANDLED EXCEPTION:
  [MonoDroid] System.Exception: Couldn't get exclusive access to the camera
  [MonoDroid] at ZXing.Mobile.ZXingSurfaceView.GetExclusiveAccess () &lt;IL 0x00033, 0x00150&gt;
  [MonoDroid] at ZXing.Mobile.ZXingSurfaceView.StartScanning (ZXing.Mobile.MobileBarcodeScanningOptions,System.Action`1&lt;ZXing.Result&gt;) &lt;IL 0x00046, 0x0028b&gt;
  [MonoDroid] at ZXing.Mobile.ZXingScannerFragment.scan () &lt;IL 0x00012, 0x0007f&gt;
  [MonoDroid] at ZXing.Mobile.ZXingScannerFragment.OnResume () &lt;IL 0x000fd, 0x00617&gt;
  [MonoDroid] at Android.Support.V4.App.Fragment.n_OnResume (intptr,intptr) &lt;IL 0x0000a, 0x0009f&gt;
  [MonoDroid] at (wrapper dynamic-method) object.2ec0fbbb-3a10-48d4-b1ab-3fe72444ec91 (intptr,intptr) &lt;IL 0x00011, 0x0003b&gt;
  </code></pre>
  
  <p>I don't know if there is a relation between the missing initialization and this error. The camera permission is set.</p>
  
  <p>Can anybody help me fixing these errors?
  Thank you in advance.</p>