- Home /
Allowing Android app to access USB device
Hi all!
I've been searching a lot for this, and I've found many similar questions. Unfortunately, I cannot seem to find the solution. Since I'm building an Android app on Unity, I'd like to bother you with my question :)
I'm using Android 7.1.2 on an oDroid, connected with an external USB camera. It's asking (during runtime) for permissions to use the USB Devices, and when pressed OK all goes well. However, the Use by default for this USB device checkbox does not really seem to do anything. Most people say that I have to use an intent filter in the manifest (located in Assets\Plugins\Android).
In application -> activity I have:
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>
Als in activity I have:
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/usb_device_filter" />
<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/usb_accessory_filter" />
These files are in Assets\Plugins\Android\res\xml . Is that the correct location?
The xml file contains:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-accessory vendor-id="2760" product-id="13424" />
</resources>
I found the vendor id and product id in the logcat while connecting.
The problem is that everytime I reboot, the messages reappear. I don't want that, because normally I don't use a keyboard.
Hope someone can help me!
Answer by Harsh1020 · May 31, 2018 at 08:17 AM
@rkauw I am facing the same issue. Could you solve the problem?
Unfortunately I wasn't able to solve it in a pretty way. The maker of Android for our oDroid has solved the need for this permission in the OS. I can choose if it's needed or not, so that's a great solution for me.
Before the OS fix, I had a very dirty (but perfect) solution. I used tab to click on the O$$anonymous$$ button location, when I expected the pop up. 99.999999999% of the times, the ti$$anonymous$$g was perfect...
Can you tell me about the OS fix because I'm using Odroid XU4 with the Lineage 14.1 rom.
Thanks, $$anonymous$$
Your answer
![](https://koobas.hobune.stream/wayback/20220612135556im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I respond to the Android broadcast "com.android.vending.INSTALL_REFERRER"? 1 Answer
Possible to use an external camera (USB) while running on Android? 1 Answer
Executing C# Code on BOOT_COMPLETED 1 Answer
Read NFC tag from Unity3d android 1 Answer
Fast communication between Android and desktop via USB 0 Answers