0

I want to set up USB tethering from an Android phone connected with windows/Linux PC and make TCP calls between each other. When I try to make TCP calls I see ENETUNREACH error. So I came to conclusion that I have to set permission in Android app to communicate with other device.

As per android developer manual, I add intent filter for USB connection as

<intent-filter>
     <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter

and permission as

<uses-feature android:name="android.hardware.usb.host" />

and in the onCreate function I try to get the USB device details as

  UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
  HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
  UsbDevice device = deviceList.get("deviceName");

But I always see that deviceList is always null, Can you please help me ?

Saby
  • 718
  • 9
  • 29
  • If you connect an Android phone with an PC the PC is the master/host and Android the slave/client. In USB host mode Android acts as the host and allows to connect other clients like USB sticks. Therefore I assume that you are on the wrong path. – Robert Aug 30 '16 at 17:45
  • See also [Enable USB Tethering Android Programmatically without user Interaction](http://stackoverflow.com/questions/14340084/enable-usb-tethering-android-programmatically-without-user-interaction) and [Detect USB tethering on android](http://stackoverflow.com/questions/7509924/detect-usb-tethering-on-android) – Robert Aug 30 '16 at 17:49

0 Answers0