Android Question USBManager keeps asking for permission

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone,
I'm using a tablet pc panel with Android.
This panel pc has a USB port that I use to communicate using a USB to TTL converter (YP-01).. the chinese ones you find on Amazon/Aliexpress (Link)... The problem is that using the USB library if the usb is removed and re-inserted it keeps asking for permission everytime! it does not store the fact that was already authorized... is there a method to prevent asking everytime?

dialog_usb.jpg



Is there a way to Wait For this permission

B4X:
Public manager As UsbManager
manager.RequestPermission(device)

Thanks in advance
 

Mike1970

Well-Known Member
Licensed User
Longtime User
Have you added the XML snippet with the device filter?

hi, yes I pasted this
B4X:
AddActivityText(main,
<intent-filter>
    <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
    <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />   
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" />
)       
CreateResource(xml, device_filter.xml,
<resources>
    <!-- 0x067b / 0x2303 Prolific PL2303 -->
    <usb-device vendor-id="1659" product-id="8963" />
</resources>
)
SetActivityAttribute(main, android:directBootAware, "true")

But with this code, everytime I plug in the USB automatically starts the application, I do not need this... I only need to remember the permission for the next time I open/insert the USB without have to grant it again
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
ok... so it could be that the vendor id or product id is wrong?
Maybe.

Where can I find such information?
You can find it with the UsbHost library or any third party USB app that shows such information.

And what would be the manifest file in the case I do not want to start the application automatically?
Everything possible is documented here: https://developer.android.com/develop/connectivity/usb/host
As far as I remember there is no such option.
 
Upvote 0
Top