USB通过Android设备与Linux PC进行Tethering并在彼此之间进行TCP通信

时间:2016-08-30 16:31:11

标签: android tcp

我想从与Windows / Linux PC连接的Android手机设置USB网络共享,并在彼此之间进行TCP呼叫。当我尝试进行TCP调用时,我看到ENETUNREACH错误。所以我得出结论,我必须在Android应用中设置权限才能与其他设备通信。

根据android开发人员手册,我为USB连接添加了意图过滤器

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

和许可为

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

在onCreate函数中,我尝试将USB设备详细信息作为

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

但我总是看到deviceList总是空的,你能帮我吗?

0 个答案:

没有答案
相关问题