Android 3.1 Usb-Host - Broadcastreceiver Does Not Receive Usb_Device_Attached

BroadcastReceiver monitoring for a specific USB device attached

If you absolutely have to create your BroadcastReceiver programatically, then you need to filter the devices programatically as well.

Try this:

public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals(UsbManager.ACTION_USB_DEVICE_DETACHED))
{
UsbDevice d = (UsbDevice)
intent.getExtras().get(UsbManager.EXTRA_DEVICE);

if (d.getVendorId() == MY_VENDOR_ID && d.getDeviceId() == MY_DEVICE_ID)
{
// Your code here
}
}
}

Android external fingerprint USB always returns false on USB permission

Might be the same issue: AndroidStudio USB: EXTRA_PERMISSION_GRANTED returns false - always

Changing PendingIntent.FLAG_IMMUTABLE to PendingIntent.FLAG_MUTABLE helped in my case.



Related Topics



Leave a reply



Submit