开发者

Sending simple commands from Android through USB

开发者 https://www.devze.com 2023-02-05 20:06 出处:网络
I am a completely new at programming, and must get this task completed for a demonstration. I have a Samsung Captivate that I need to send simple messages to a device over USB. I\'m not worried about

I am a completely new at programming, and must get this task completed for a demonstration. I have a Samsung Captivate that I need to send simple messages to a device over USB. I'm not worried about having the droid act as host, not the issue here. I just need to find the proper code to access the USB functions in Android 2.1. I need to send simple on/off commands and audio level changes.

It would seem to开发者_运维知识库 me that this shouldn't be that hard, as the droid will communicate with my laptop and act as a storage device, so I know the two can talk. Can anybody help me find these resources? I have been looking extensively, to no avail.

Thanks!

Bill


The simplest solution would be to use the Android Debug Bridge (ADB) which comes with the Android SDK. It allows to connect to your Android device via USB (AFAIR USB debugging must be enabled on the device).

If you want to send your commands from a custom [Java] app on the host you could try to use the ADB feature to forward ports from the host onto the device. Your app on the device could listen to the port and therefore you would have a simple TCP connection between device and the host over USB.


As Falmarri suggests, there is no access to USB from the SDK. From custom firmware, yes, but not the SDK.

0

精彩评论

暂无评论...
验证码 换一张
取 消