PC to Android communication over USB cable - java

I need to make communication between PC software (written in java) and android app over usb cable. The PC software will send some data (Strings) to Android app witch will accept those strings and do some action depending on the message received.
What is the best way to do this?
I am looking all over the internet and can't find any solution to this. If someone has example of this communication i would be very grateful.
I already done this communication over sockets, put i need to cover situation if there is no router or internet connection.
Thank you

Check following article. I guess similar question to your on SO.
If you want to communicate between Android USB device and some USB host you need to use the accessory mode (https://developer.android.com/guide/topics/connectivity/usb/). But this mode requires special driver support on the USB host side (which is your PC).

Related

Android USB application

I have a have been doing my research on a program in which an android application makes a communication with a Desktop computer through a USB connection. I did find out that Android 3.1 allows USB communication, but I have no idea how to proceed on it. I'd be very helpful if someone could tell me how this is done.
Thanks
Nik
You can use this API.
Accessory Development Kit
More detailed information can be had from this link as well.
Android apps, communicating with a device plugged in the USB port
I am not sure you can test this using an emulator.So develop an application and deploy it in a real device and connect that device to your PC via USB port for testing.

Android usb host serial communication with custom made board

I'm working with an android 4.0.3 tablet. I need it to communicate with a custom made board via USB serial at 9600 baud rate. The custom board's usb port allows serial connection. I was wondering of someone can point me in the direction on how i can get my application on my tablet to send and receive some information between the two. All the help is appreciated.
Dogz1
You should use USB Host API for doing this. The API documentation explain how to use the USB Host API, step by step in the official documentation page here : http://developer.android.com/guide/topics/usb/host.html
Also if you are working with something like an Arduino Board, and if your board has USB host capability, I would recomment using ADK for communication.

Android WiFi sending and receiving information

Sorry for kind of a dummy question, but I'm wondering how to work with WiFi connection via android. My application needs to transfer some data (both receiving and sending) with PC or with other android device using WiFi. How should I organize the process? I mean, how should I establish connection, then should I open a socket for data transfering, etc. Is there any way to do it without internet connection, smth like bluetooth, except wifi.p2p (which is only available for android 4.0)? Would be grateful for as detailed manual as possible.
Every network connection even if only in the local network or localhost reqieres the INTERNET permission.
Bluetooth and NFC might be an option, but I have no experiance with that.

Android app and native desktop app comunication

I have a native application written in C++. I would like to write an Android application that would be able to comunicate with my native application when user is in connected to the same WiFi network as my PC.
How this things are done. I mean what technologies are used behind it. Maybe you have some samples?
You could use a peer-to-peer library, like AllJoyn from Qualcomm. The idea is that both your PC and the Android device will use TCP/IP to communicate with each other. You still need a protocol above that however that will handle discovery, session establishment and exchange of data.

Sending commands from iPhone to Android

I need to send some commands using the wireless network from an iPhone application to an Android application. I thought a possible way would be to send the commands as strings over TCP (SOAP seemed a better solution, but it seems some libraries would be necessary and it is not necessary). Is there anyone out there who can address me to some documents or some place to start this kind of applications?
Thanks!
The simple answer to this question is that you need to listen on a specific port number by opening a Server Socket on the Android side, and from the client side (iPhone) open a socket connection towards the Android's IP address and port.
Luckily sockets are a pretty standard thing nowadays and behave typically the same across operating systems, that is Linux, Windows, Mac OSX, and iPhone iOS, Android and Symbian.
The only difference you have is which programming language you need to use. On Android you have to use Java. So if an Android application is waiting for the connection your application needs to open a ServerSocket and listen of incoming connections.
From the iPhone part, your application needs to be developed in Objective C. Nothing fundamentally different, but the programming language is different.

Categories

Resources