Exemplo n.º 1
0
        private void setBroadcastReceivers(Context context, Intent intent)
        {
            mUsbReceiver.OnReceive(context, intent);
            string action = intent.Action;

            if (ACTION_USB_PERMISSION.Equals(action))
            {
                lock (this)
                {
                    UsbDevice device = (UsbDevice)intent
                                       .GetParcelableExtra(UsbManager.ExtraDevice);

                    if (intent.GetBooleanExtra(
                            UsbManager.ExtraPermissionGranted, false))
                    {
                        if (device != null)
                        {
                            // call method to set up device communication
                            UsbDataBinder binder = new UsbDataBinder(mUsbManager, device);

                            var a = mHashMap[device];
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void setBroadcastReceiversAttached(Context context, Intent intent)
        {
            mUsbAttachReceiver.OnReceive(context, intent);
            string action = intent.Action;

            if (UsbManager.ActionUsbDeviceDetached.Equals(action))
            {
                UsbDevice device = (UsbDevice)intent.GetParcelableExtra(UsbManager.ExtraDevice);
                if (device != null)
                {
                    UsbDataBinder binder = mHashMap[device];
                    if (binder != null)
                    {
                        binder.onDestroy();
                        mHashMap.Remove(device);
                    }
                }
            }
        }