01-12-2011 06:04 PM
I have been using the USBPortListener to try and get an indication as to when the USB cable has been plugged into the phone, and also when it gets diconnected. The problem is that only one function ever gets fired, and that is "getChannel", whenever I transmit data over the connection.
Obviously I must have a misunderstanding on how to use this listener, but I woud assume "connected" fires every time the cable is plugged in, same with "disconnected".
Solved! Go to Solution.
01-12-2011 09:11 PM
I think you want to use a system listener for this
01-13-2011 11:24 AM
Thank you, jonberry! That was just what I needed.
After implementing that, I got to thinking about the port listener again. Is there a nicer way to be able to tell when data has come in over the cable instead of reading the input stream over and over? I tried to use the USBPortListener's dataSent, dataReceived, and patternReceived and neither of these do anything...
01-13-2011 12:08 PM
Take a look at the USB sample in the demos.
I haven't tried this in a long while but I think the dataReceived method should work.
Make sure you've added a listener to your app. ![]()
01-13-2011 12:59 PM
Again, thank you. You pointed me in the right direction. I see the problem now; you have to register the channel first before you can get the callbacks.
I wish the documentation would tell you this little detail first...