我使用Zxing来扫描QR码。这是我的代码:
public class ScanActivity : Activity
{
public ZXing.Result scanningResult;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.activity_scan);
mReturnValue = new Intent();
Button scanBtn = FindViewById<Button>(Resource.Id.button_scan);
MobileBarcodeScanner.Initialize(Application);
scanBtn.Click += async (sender, e) =>
{
var scanner = new ZXing.Mobile.MobileBarcodeScanner();
scanningResult = await scanner.Scan();
// if (scanningResult != null)
// Console.WriteLine("Scanned Barcode: " + scanningResult.Text);
};
我的问题是我无法在另一项活动中找到并使用扫描结果的值?
答案 0 :(得分:1)
从您需要结果的活动中,您应该开始扫描结果的活动。在调用活动OnActivityResult事件中,您可以使用重新调整的代码执行所需的操作。
看一下样本:
https://developer.xamarin.com/recipes/android/fundamentals/activity/start_activity_for_result/