Android tablet app send receive data from usb - android

I want to build an app for my android tablet that will receive and send data to two usb devices on different ports. Before I start I'd like to know if such thing is possible?

Absolutely possible.
I'm currently developing on a Toshiba Thrive for a USB data acquisition device, and I can route through a USB hub to access multiple devices.
You should make sure you are developing on a device that supports USB host mode (the galaxy is known to have usb issues, while the Toshiba Thrive does quite well with a full size USB type A port). I'd also recommend running honeycomb at least, ICS and JB are better. Yes, I know the API has been backported, but again, users have reported issues.

Related

How to use SpaceDesk over a Wired Connection?

I have a Samsung Galaxy Tab A 10.1" that I want to use as a second monitor with my PC. Spacedesk works great for my needs so long as I'm on a network with lots of bandwidth -- but more frequently I want to use second-monitor functionality in other environments, e.g. at a coffee shop, where the number of users bogs down network traffic and makes Spacedesk unacceptably slow.
Spacedesk doesn't natively support a wired connection, but for those who want one they suggest using USB tethering, presumably so both devices are on the same network. Problem is, my tablet is the Wifi-only version, so USB tethering isn't enabled. I rooted the device and used adb to run the commands enabling USB tethering as an option. It didn't take - the option never appeared under Settings / Connections. Then I installed ClockworkMod Tether as a 3rd party usb tether app. The PC tether software said it connected successfully to the tablet, but Spacedesk couldn't connect. Next I tried "gnirehtet", a reverse-tethering app. Got it working fine, but again Spacedesk on the tablet couldn't find the Spacedesk server on the PC.
How can I get both devices to be on the same network, without an intermediate connection (e.g. a router), in a way that preserves my PC's ability to connect to wifi, and that will allow Spacedesk to connect?
Turns out there's this thing called "Mobile Hotspot". Of course I couldn't use this on my tablet, as it had been disabled (thanks Samsung). But you can set it up on Windows easily -- in Windows 10 it's under Settings / Network & Internet / Mobile Hotspot. Connect your tablet to that hotspot and Spacedesk works like a charm.
Huge thanks to SpaceDesk customer support, who were extremely helpful in troubleshooting this apparently rather unusual situation. 5 stars both for the product, which I can now use anywhere, and the customer service.
Wifi tethering is possible with the tab A but only on android versions 6.x and below. it can be turned on via usb tethering enabling apps found in the app store that take you to the options in the settings of your device, these options appear to just be hidden in versions lower than 7 but removed in android 7 for whatever reason as the same apps just take you to an empty screen when used with 7.
If you have already upgraded to android 7.0 or above, and having spacedesk work with minimal lag is important to you, then I suggest you roll back youre tablet android version using Odin. This is what I've had to do after updating my tablet today (google it, there's plenty of guides out there)
TBH spacedesk is just poop over wifi. With USB you can watch video no problem
I tried the advice suggested here of using the mobile hotspot on my Windows 10 PC and used an old android tablet to create the extended screen to my PC using the suggested SpaceDesk app and it worked great! The download for Spacedesk for your Windows 10 PC is at https://spacedesk.net/ and the android app is in on the Google Playstore. Give it a try; it worked great for me.
I was connected to the internet over the LAN on my WIFI so I had difficulty in connecting the tablet (Samsung Galaxy Tab 3) over USB. My solution to this problem is disconnect your Laptop from the WIFI router from LAN cable as well as WIFI and use the tether option in tablet and connect it to the laptop and now it will work. Now for using the inter connect your Wi-Fi or LAN cable after this.
I tested the #Twiffy solution "Windows 10 hotspot" and worked for me. I disabled the tablet (Galaxy Tab A7) WiFi and the lag ended.

Can anyone confirm any tablet supporting USB Host Mode and Anyone have tested with code implementation

I want to make communication between tablet and a SoC. For this the tablet must support USB Host Mode APIs. As per Android.com, any android device having android version 3.1 or above should support it but in reality it's not true. Tablet manufacturers may have their own implementation too. So before buying a tablet I want to be 100% sure that the tablet I'm buying supports this functionality.
I am particularly looking for some popular western tablets like Samsung Galaxy Tabs, Acer Iconia Tabs, Sony Tabs ...
If anyone can confirms that this XXX tablet supports this facility, can he also test it with usb sample application or provide some links. It would be so generous of him.
Reference: https://stackoverflow.com/questions/10212433/confused-with-usb-host-mode-compatibility-on-different-devices
The OEM can only tell you that whether host mode is supported for xxx tablet or not. But there is a simple APP exist in android market named "usb host controller". download and install it on the device u want to check for host mode capability. In the info tab it will display that whether it supports or not and if supported, active or not and stuff like.
Hope it will solve ur problem.
So I tried things out today,
MTP & PTP
Connecting tablets to each other:
it seems that connecting the nexus 7 with for example my Mediapad (with mtp enabled on the mediapad), does not work at least not for FX file explorer it does not show any usb storage for example. This is because I think FX explorer has no build in mtp support.
Set up example:
Mediapad <-- (Micro to male A) --> <-- (Female A to micro OTG cable) --> Nexus 7
When turning on ptp instead of mtp the nexus automatically opens the gallery app and shows all the images from my mediapad. So android supports reading ptp devices as well as pretending to be a ptp device. But we can't say the same about mtp, because android can't read mtp devices or at least the app I used couldn't. But connecting a android device to your computer using mtp works off course.
I also tried this visa versus so reading the nexus files, the same results.
When connecting a phone that does not support mtp to my tablet(Mediapad) things work out fine, the file explorer on my tablet finds the connected usb device.
Using keyboards and usb sticks
Reading usb sticks, keyboards, hubs etc works for the Mediapad.
The same for the Nexus 7 but I did not get usb sticks working on FX file explorer may be because of the fact I don't have the full version of the app on that device.
It's late here in Holland, tomorrow I will get the full version and try it out again cause it seems that it should be possible.
USB according to the developers site
So I started reading the USB developers guide, as far as I can tell I think reading a mtp device from another android tablet should work, but you will have to build the code for it your self.
At the moment I don't have much time to do any more research, but in the feature I will eventually try it all out my self with some coding.
A small conclusion:
Reading another tablets files when the tablet you want to read only supports MTP mode is not possible by default, but it could be made possible using the usb api.
Reading usb devices using the host mode works fine for the Mediapad and for the Nexus 7 so far. For the Mediapad I’m 100% sure, and for the Nexus 7 because I don't use it that often 99%.
Not sure if this if what you wanted to know, but I really hope you can do something with it. And I hope some more people will be interested in this topic and post there thoughts on it. I'm not really a usb developer my self so its all kinda new for me to, and I hope my poor dyslexia-hollandia English will not ruin your day ;)
Some tablets like Lenovo Thinkpad just have a regular USB connector, same as laptop. They do support USB host mode. If you are not sure if the micro USB (OTG) will work or not, just a use tablet that fetures a separate "normal" USB port.
For me Samsung Galaxy Tab 10.1 worked quite well. I managed to integrate the RFID ME USB RFID reader. Of course you would need the Samsung Galaxy Tab SD Card and USB Adapter too.

Which devices do and do not support USB Host mode?

Could someone please provide a comprehensive list of which devices do and do not support USB Host mode out of the box with no rooting, OS rebuilding, or cable hacking required? I've read that only tablets support it. Then I've read that the Droid supports it. Many posts are a couple years old so not sure what is applicable now in March, 2012. I've read that Windows phones support it? Maybe its time to switch to that. Does iPhone 4s support it?
There is a pretty good chart, based on user submissions from actual devices here:
http://usbhost.chainfire.eu/
You can read the forum thread for more details on the methods for data collection:
http://forum.xda-developers.com/showthread.php?t=1493325
I was also struggling to find which of the devices support USB hosting. After trying various devices it is clear that just having Android 3.1 or higher does NOT guarantee that your phone support USB Hosting.
I came across this Google Spread Sheet which lists various devices with USB Hosting.
You can also contribute to this list by submitting your responses through this Google Form.
Hope this helps !
"Provide a comprehensive list?" Pretty tall order there, pardner ;)
Nevertheless, support for USB Host Mode is available on Android 3.1 or higher:
http://developer.android.com/guide/topics/usb/host.html
Here's an extremely interesting article about interfacing an Arduino to an Android:
http://createdigitalmusic.com/2011/05/android-adds-usb-host-mode-open-hardware-development-with-arduino/
And you can Google for specific Android 3.1++ devices that support USB Host Mode (including, of course, the Xoom tablet)
'Hope that helps
EDIT: I have found a very helpful answer which worked for me (on Yarvik TAB464) and enabled a full USB host mode: Android USB host and hidden devices - however I expect it to work on rooted tablets only :( (it seems that the Yarvik tablet comes pre-rooted).
OLD ANSWER: This is pretty frustrating. Many tablets claim to support USB HOST mode, but only a selected subset of the devices are supported: mouse, keyboard, mass storage and that's it. For example, http://www.yarvik.com/en/products/tablets/tablets_10/TAB464/ claims to support USB HOST mode; a mouse connected to the tablet works, but owner.getPackageManager().hasSystemFeature("android.hardware.usb.host") returns false and UsbManager.getDeviceList() returns always empty map, so it certainly does not support all USB devices (both 4.0.3 and 4.0.4 versions of Android provided by Yarvik). Installing Cyanogen on the device may perhaps help but this is something I would like to avoid, because of possible stability issues.
Also, Samsung Galaxy 10.1 Tablet does not work, according to Android Usb Host Problem with Samsung Galaxy 10.1 Tablet
There is only a handful of devices which actually support full USB HOST functionality out-of-the-box, but I have yet to see a complete, up-to-date list with all items actually verified. I confirm that the ASUS Transformer TF101 has full USB HOST mode, however I tested it on a rooted device only, not on the "vanilla" firmware.
Here is another list of devices with full USB HOST mode, but please take it with a grain of salt:
http://www.lonelyplanet.com/thorntree/thread.jspa?threadID=2114206
The Toshiba Thrive has one full USB port.
Lenovo ThinkPad Tablet has a full USB port.
Acer Iconia Tab A500 one full USB port.

developing a special device communication app that connects through USB port on Android

I found the USB docs for Android and from there it seems as if one could write a communication program on an Android phone that works exactly like on a PC.
I have a normal USB-cable that normally connects between a PC and an external device. On one end it is a normal USB on the other end it has a special plug for the device.
If I get an USB female-female adapter I could connect my normal Android phone cable USB end to my device USB cable and so basically plug in my special USB cable into the Android phone.
Does anyone have experience doing USB communcation programming on Android - basically copying normal PC USB functionality? All I would have to do is sent and receive text strings over the USB port - just like on a PC.
Is this possible or is the USB port programming on Android limited in any way
and not really identical to USB programming on a PC? eg. power supply through USB or anything else?
ps on the PC I need to have a FTDI driver installed to work with the external device.
Many thanks
UPDATE:
it seems that starting with Android 3.1 it is possible to do this - however, if I understand htis correctly, Android 3.1 runs only on tablet Android devices - I might be wrong with this - compared to Apple this all this pretty confusing (however, with Apple iPhone it will never work! ;)
Yes, Android supports USB host on 3.1 and newer, so you can connect USB devices directly to an Android device using a converter cable. Android 4.0 brings this feature to handset devices.

External USB devices to Android phones?

I would like to use Android phones as a way to do some processing and visualization of a sensor that would be attached to the USB port on the phone. The sensor would plug into the micro/mini USB, and then I would need to read the incoming data from the USB serial port.
Is this possible? I have heard of people using Android to steer robots and other applications, but I have never seen Android being used as a host for a USB sensor. I can't seem to find any official documentation on the subject either, but it seems like it would be a very useful tool. Any thoughts, links, or information on this matter? Thanks.
What you're looking for is USB Host support.
There's an open issue in Android's issue tracker here for it:
http://code.google.com/p/android/issues/detail?id=738&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
and it's actually ranked 7th, in terms of "stars" (think votes, by the people), at 1110 stars. You can log in and star it yourself, both to vote for it, and to receive email updates.
There was also work on a patch back in February, 2010:
http://groups.google.com/group/android-kernel/browse_thread/thread/c8471573d7553331
and there's info on using a USB keyboard here:
http://www.tombom.co.uk/blog/?p=124
Perhaps you can find something for your sensor there?
This is cool =):
http://www.technologyreview.com/biomedicine/25286/?a=fb
Cheers,
Victor
should be possible, look up android.hardware.usb.UsbDevice # http://developer.android.com/reference/android/hardware/usb/UsbDevice.html
This support has been added since Android 3.1.
Look at http://developer.android.com/guide/topics/connectivity/usb/index.html
This guy has modded his Nexus One to work as a USB host and has done several cool things.
He uses a USB keyboard and runs a movie from his USB stick. Then he runs a webcam through the phone and displays it on the computer and even runs an entire desktop-based Linux distro from his phone onto his computer monitor.
Pretty amazing stuff.
http://sven.killig.de/android/N1/2.2/usb_host/
The USB defines two type of equipment 1 usb host 2usb device .A device can only be attached to a host,no host to host or device to device connection.,in the beginning usb hosts were computers to which a usb device is attached.but with increase in popularity of usb interface a number of equipments come as usb host ie you can attach your pendrive and other usb device to it.In the starting mobile phones were manufactured as usb device ie you can attach your phone to usb host only typically a computer.but there also revolution come in now we have phone which can act as host and device when it is working as host we can attatch printer to it and when it work as device it can be attatched to a computer.only high end phone has this support.low end phones are still usb devices.
so we have two options
phone in usb host mode and your senser as usb device(you will need microcontroller that can act as usb device for this purpose-eg pic 18f2550 microcontroller);
your phone as device and your senser circuit as usb host here you will need high end microcontrollers that can act as usb host
in both cases there involves coding at both phone and senser circuit microcontroller
i dont know anything about phone side coding but i think this helps you to get a direction to what to do.
Have a look at You Are Here GPS.
https://play.google.com/store/apps/details?id=com.agbooth.usbgps

Categories

Resources