0
我想創建一個簡單的自己的QR碼閱讀器。爲此我組合了一些來自互聯網的腳本並使其正常運行。但是「真正的」掃描儀應用程序沒有打開。Xamarin Android ZXing Mobile不開放
這是我使用的代碼:
public class MainActivity : Activity
{
MobileBarcodeScanner scanner;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
MobileBarcodeScanner.Initialize(Application);
ZXing.Net.Mobile.Forms.Android.Platform.Init();
showScanner();
}
private void showScanner()
{
scanner = new MobileBarcodeScanner();
scanner.UseCustomOverlay = false;
scanner.TopText = "Hold camera up to barcode to scan";
scanner.BottomText = "Barcode will automatically scan";
scanner.CancelButtonText = "Done";
scanner.FlashButtonText = "Flash";
var opt = new MobileBarcodeScanningOptions { DelayBetweenContinuousScans = 3000 };
scanner.ScanContinuously(opt, HandleScanResult);
}
private void HandleScanResult(ZXing.Result result)
{
string msg;
if (result != null && !string.IsNullOrEmpty(result.Text)) // Success
{
msg = result.Text;
}
else // Canceled
{
msg = "Scanning Canceled!";
}
}
}
從我的理解這應該工作。但事實並非如此。
我還使用在AndroidManifest.xml這些行:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
我在做什麼錯?