/// <summary> /// 在ContextWrapper Register時呼叫 /// 同步RegisterReceiver /// </summary> public void OnResume() { if (IsRegistered) { return; } contextWrapper.RegisterReceiver(this, new IntentFilter(scanservice_result)); IsRegistered = true; }
USBBroadCastReceiver _USBBroadCastReceiver; // The permission broadcast receiver for USB permission intent /// <summary> /// We initialize all Android context /// </summary> /// <param name="context"></param> public void Init(Object context) { _context = (ContextWrapper)context; _devHandle.usbManager = (UsbManager)_context.GetSystemService(Context.UsbService); _usbPermissionIntent = PendingIntent.GetBroadcast(_context, 0, new Intent(USBBroadCastReceiver.ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(USBBroadCastReceiver.ACTION_USB_PERMISSION); _USBBroadCastReceiver = new USBBroadCastReceiver(); _USBBroadCastReceiver.NotifyUsbPermissionCompleted += _USBBroadCastReceiver_NotifyUsbPermissionCompleted; _context.RegisterReceiver(_USBBroadCastReceiver, filter); }