Add support for UsbManager.USB_DEVICE_ATTACHED action as described in https://developer.android.com/guide/topics/connectivity/usb/host.html chapter "Working with Devices".
This enabled the driver to receive the UsbManager.ACTION_USB_DEVICE_ATTACHED intent, which will be forwarded as ACTION_SDR_DEVICE_ATTACHED intent. The receiving application uses the already existing mechanism as described within the README.md to start the RTL-SDR driver. But to ensure that the RTL-SDR driver initialises the newly attached USB device, the application needs to add the received USB device from the ACTION_SDR_DEVICE_ATTACHED action to the new intent as follows:
public static final String ACTION_SDR_DEVICE_ATTACHED = "com.sdrtouch.rtlsdr.SDR_DEVICE_ATTACHED";
...
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (intent.getAction().equals(ACTION_SDR_DEVICE_ATTACHED)) {
UsbDevice usbDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
Log.i(TAG, "USB attached: " + usbDevice.getDeviceName());
Intent newIntent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("iqsrc://-a 127.0.0.1 -p "+ port + " -s "+ samplerate));
newIntent.putExtra(UsbManager.EXTRA_DEVICE, usbDevice);
startActivityForResult(newIntent, 1234);
}
}
The following intent filter need to be added to receive the ACTION_SDR_DEVICE_ATTACHED intent:
Add support for UsbManager.USB_DEVICE_ATTACHED action as described in https://developer.android.com/guide/topics/connectivity/usb/host.html chapter "Working with Devices". This enabled the driver to receive the UsbManager.ACTION_USB_DEVICE_ATTACHED intent, which will be forwarded as ACTION_SDR_DEVICE_ATTACHED intent. The receiving application uses the already existing mechanism as described within the README.md to start the RTL-SDR driver. But to ensure that the RTL-SDR driver initialises the newly attached USB device, the application needs to add the received USB device from the ACTION_SDR_DEVICE_ATTACHED action to the new intent as follows:
The following intent filter need to be added to receive the ACTION_SDR_DEVICE_ATTACHED intent: