I want to ask if there is an application in which a user can connect USB to Android via an OTG cable device and play the media contained therein (especially video).
I made a broadcast receiver to detect a connected USB, I also want to read it. I am using this piece of code.
private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) { synchronized (this) { UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if(device != null){ // Log.d("1","DEATTCHED-" + device); } } } // if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) { synchronized (this) { UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) { if(device != null){ // Log.d("1","ATTACHED-" + device); } } else { PendingIntent mPermissionIntent; mPermissionIntent = PendingIntent.getBroadcast(MainActivity.this, 0, new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_ONE_SHOT); mUsbManager.requestPermission(device, mPermissionIntent); } } } // if (ACTION_USB_PERMISSION.equals(action)) { synchronized (this) { UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) { if(device != null){ // Log.d("1","PERMISSION-" + device); } } } } } };
I want to make such an application.
Does anyone have an idea about this?
source share