Android USB read/write is working only by reconnecting cable - java

I am working with Java Eclips, galaxy tab 2 android 4.1.1
I have a device that is connected to the USB and I can write and read from/to it.
my problem is that I can read/write to the device only if I turn on the app by replugging the USB cable, if I close the app and try to switch it on by icon the USB is not reacting by read and write
while I try to connect to the USB I have no errors it seems like success but the write gets and exception :
"ENODEV (No such device)"
dose some one can help?

I know that there is already 2 years left since a question posted but I would like to post an answer anywhere.
You face with a well know Android USB bug
https://code.google.com/p/android/issues/detail?id=59667
What I do in this way is simple parse an error and display a Alert Dialog that it is necessary to unplug and plug USB cable.

Related

Bluetooth HID in Android (Java)

I have a Wii remote and I want to connect it to my android phone with just Java if possible. I have tried to look for libraries and other things like that but there was nothing. I am new to Bluetooth development, I don't know how it works entirely. Other than that, I would love to get some links on how to connect a Bluetooth device as an HID and send data to a specific address. Thank you all!!!!

133 error while connecting to BLE devices on some Android Device (Samsung)

I am developing application with a BLE device "Puck Js". I required to connect to this device using a android application on some of devices.
One Some of the devices we are able to connect and all the things are working fine. But on some devices specially Samsung and some other custom os versions.We are some issues in pairing the device.
While connecting to the device we get 133 error and connection is not made sometime device get paired but later it get disconnected and not able to reconnect to device.
One more issue we are getting. In one device we are not able to detect the services running on the puck device. Which we have installed using the custom js script i have also asked earlier. (After restarting the (Android)device it start detecting).
Please help us to resolve this issue.

USB-connection from android to phone

I'm trying to send data from android to a computer via USB,
I found the USB Accessory introduction, http://developer.android.com/guide/topics/connectivity/usb/accessory.html (Basically I want to send a few bytes to a programm on the computer) So, am i right on using the accessory on android? What would i use for the pc programm, and can I/ Do i have to create a socket connection from my application to the programm
You will need access to the USB device plugged in to the PC which lets you send USB Control Request and Bulk Transfer requests.
If you are using linux, you could try libusb - which is pretty straight forward to use. For windows am not sure though.

Bluetooth Android issue

I am running a multi thread application on android and adobe air, in native android 2 bluetooth sockets are set up and a couple of server threads for the air app to communicate with the bluetooth sockets of native android. It's basically socket programming and it all works on one device I used to programme it.
The device i used to develop this app was slow, i therefore got myself another tablet to test (android vega) and it is very fast at communicating my bluetooth data as it has 2.1edr version.
The problem is with the Advent Vega tablet the bluetooth streams just disconnect for no apparent reason intermittently and in the adb log window i just get trying to connect to device all of a sudden when the disconnect occurs, i have no mention of the crash anywhere in the log, this happens to both bluetooth connected threads at the same time so it must be something to do with the bluetooth radio im suspecting. The other tablet device runs the app fine but slower (no disconnects). I have even installed a custom 3.0 rom on the vega to see if it was a os problem but the disconnect problem persisted on 3.0 as well.
Due to the fact there is no mention of this in the adb log i am just basically staring at a screen with no idea of why it disconnects for 2 days now!! The only way to get the app to run again after this disconnection occurs is to restart the bluetooth on the device but this disconnect occurs again eventually when next run. It seems to improve the amount of time it stays alive tansferring data when the app is first run afater a re boot.
I have gone through all code of the run() and stopping() of each thread and it seems to exit gracefully, i close the bluetooth sockets only, it seems from research no need to close the bluetooth input and output but i have also tried that approach to closing.
Can anyone offer suggestions as to why both bluetooth read/write loops would just stop all of a sudden and disconnect? Seemingly effecting the adb log as well as it just says trying to connect...
Or any suggestions as to how to better debug when this occurs?
Or even what somebody else would do in this situation.
Hope someone can help, i have a great phone remote app for the android tablet owner community and it hinges on this final issue which i have been stuck on for 2 days.
I had problems with disconnects, and implemented a keepalive by sending a ping request and a ping ack.
This worked fine for me...

Detected android device connected to PC

I have an android devic, i wish to know when it is connected to the pc via java/.net
i know its possible - the Samsung New PC Studio is doing it, when ever i connect an android device it lets me know. how can i achieve the same?
You have to listen for one of this notifications
http://developer.android.com/reference/android/content/Intent.html
If you're using it as a mass storage device then use this
http://developer.android.com/reference/android/content/Intent.html#ACTION_UMS_CONNECTED
Other USB events aren't clearly described in the documentation
EDIT:
If you want to read on the computer side I would read this article
http://today.java.net/article/2006/07/05/java-and-usb
and then check which kind of devices are connected to the usb port. if it is a mobile phone, then you can try to send a short message to it. on your phone you make a small piece of code which returns an appropriate answer so you can detect thats its really android/your phone/this phones you want to identify
java device detection
This site have a guide on how to detect device with java web and java core
http://51degrees.com/Support/Documentation/Java/GettingStarted.aspx

Categories