Reputation: 575
I don't want to take permission to connect to USB accessory as i want to connect to a specific USB accessory. Is it possible . As i have read on android.com as follows
Note: If your application uses an intent filter to discover accessories as they're connected, it >automatically receives permission if the user allows your application to handle the intent. If not, >you must request permission explicitly in your application before connecting to the accessory.
So is it possible to do so. Please help.
Thanks Gaurav
Upvotes: 2
Views: 1832
Reputation: 2029
You can listen for the intent with this code:
UsbAccessory accessory = (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
However there is information that must be included in the manifest:
http://developer.android.com/guide/topics/connectivity/usb/accessory.html#manifest
This will allow you to filter devices based on a number of attributes.
Upvotes: 3