Reputation: 166
I have an Android device without a screen. When connecting the USB device automatically appears the system dialog to permit the use of USB. It is necessary to obtain a permit without using the device's screen.
It is assumed that the device application will be installed in advance, and when the USB device is connected automatically.
How exactly can this be done?
Upvotes: 8
Views: 40408
Reputation: 181
Add to activity in manifest file
<activity ...>
...
<intent-filter>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="@xml/accessory_filter" />
</activity>
Create file with params of your usb device in res/xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-accessory manufacturer="Google, Inc." model="DemoKit" version="1.0" />
</resources>
Fore more information see https://developer.android.com/guide/topics/connectivity/usb/accessory.html
Upvotes: 4