//[MethodImpl(MethodImplOptions.Synchronized)] public override void OnReceive(Context context, Intent intent) { //intent.SetAction(ACTION_USB_PERMISSION); //intent.SetAction(UsbManager.ActionUsbDeviceAttached); //intent.SetAction(UsbManager.ActionUsbDeviceDetached); // Do stuff here. string value = intent.GetStringExtra("key"); string action = intent.Action; logMsg(DateTime.Now + " Line:219: Action name:" + action); if (ACTION_USB_PERMISSION.Equals(action)) { logMsg(DateTime.Now + " Line:219: ACTION_USB_PERMISSION1"); UsbDevice device = (UsbDevice)intent .GetParcelableExtra(UsbManager.ExtraDevice); logMsg(DateTime.Now + " Line:219: ACTION_USB_PERMISSION Device" + device); if (intent.GetBooleanExtra( UsbManager.ExtraPermissionGranted, false)) { if (device != null) { mReader.Open(device); logMsg(DateTime.Now + " Line:219: ACTION_USB_PERMISSION OPEN"); new OpenTask().Execute(device); byte[] buffer = toByteArray("02"); mReadKeyOption.TimeOut = buffer[0] & 0xFF; } } } else if (UsbManager.ActionUsbDeviceDetached.Equals(action)) { logMsg(DateTime.Now + " Line:219: ActionUsbDeviceDetached"); //// Update reader list mReaderAdapter.Clear(); foreach (UsbDevice device1 in mManager.DeviceList.Values) { if (mReader.IsSupported(device1)) { mReaderAdapter.Add(device1.DeviceName); } } UsbDevice device = (UsbDevice)intent .GetParcelableExtra(UsbManager.ExtraDevice); //logMsg(DateTime.Now + " Line:219: ActionUsbDeviceDetached::" + device); if (device != null && device.Equals(mReader.Device)) { // Clear slot items mSlotAdapter.Clear(); // Close reader System.Console.Write("Closing reader..."); new CloseTask().Execute(); } } else if (UsbManager.ActionUsbDeviceAttached.Equals(action)) { logMsg(DateTime.Now + " Line:268: ActionUsbDeviceAttached::"); //if (deviceName != null) { // For each device foreach (UsbDevice device1 in mManager.DeviceList.Values) { // Request permission mManager.RequestPermission(device1, mPermissionIntent); //requested = true; break; // } } // } } }