I have to read and write data to the COM ports of a device using Android. I am using javax.comm package for that, but when I installed the apk file, it is not displaying any ports of the device. Is there any permission which I need to add in the manifest file?
Share
Your problem is one with operating systems. Android runs Linux under the hood, and Linux treats serial ports differently than Windows does.
javax.commalso containswin32com.dll, a driver file, which you won’t be able to install on an Android device. If you do find a way to achieve what you’re trying to do, you can’t actually look for a “COM” port in a Linux environment. The serial ports will go by different names.So, hypothetically, if your idea were to work, you have to look for these names.
Luckily for you, Android does have provisions for interfacing with USB devices (Which I assume you want to connect to, as opposed to parallel or RS-232 ports). To do this, you will set up your device as a USB Host. Here’s what you’ll want to do:
USBManager.USBInterfaceandUSBEndpoint.Here’s my rough estimate of how you’ll do it. Your code will, of course, have a more mature way of doing things.
Extra material for your reading pleasure: http://developer.android.com/guide/topics/connectivity/usb/host.html