Communicating with a website via usb connection to a Xamarin.Android app - android

I have a specific requirement where an Android device cannot have any WIFI/Internet connection. However, the android device can be connected to a Windows machine (that has network capabilities) with an USB cable.
Is there a way to transfer data from the android app(Xamarin.Android) to the Web Application(.Net Core 2 )? Maybe some way for me to hit the controllers via USB connection (Or alternatively bluetooth if this option is not available).

Is there a way to transfer data from the android app(Xamarin.Android) to the Web Application(.Net Core 2 )?
Generally, this is done by certain tool, which enables the TCP transactions between your android device and your PC. ex: Port Forwarding.

Related

Android to Android Communication over USB

Basically I need to build an APP to communicate between two android devices, send and receive data, in the safest way without Internet.
I could use WiFi, but they are prone to hacks and Jamming. My first question is
if Local WiFi Hot Spot connection could be made fully secured to public?
I am looking into wired communication between android devices using OTG USB serial communication. My second question is
Are there ways to communicate between android devices over OTG-USB using serial ports?
As Android supports both USB gadget and USB host interface, it is definitely possible to make communication between two devices over USB OTG. In this case, your one device will become USB Host which will initiate connection. And the other will become USB gadget device. And you will have to write application considering that.

Stream data from Android device to desktop computer when they are connected to different networks (Android WiFi, computer Ethernet)?

I am trying to make an android application that will stream live sensor data (e.g. accelerometer, etc) from my android device to my desktop computer.
My android device is connected to a WiFi network and my desktop computer is connected to a network with an Ethernet cable.
There are android applications available that send data from an android device to a PC via WiFi, but both devices must be connected to the same network.
Is there a way to transfer data if the two devices are connected to different networks?
Thank you!
Due to the fact that nearly every network sits behind a firewall (in most cases your home router/nat-device) you need to implement port-forwarding to access network 2 from network 1.
Another aproach would be to set up a VPN (f.i. with SSH) between the 2 hosts.
If your PC is directly connected to the internet, and has a public ip (that means, if you have NOT a RFC 1918 Adress), then you are able to directly connect to that ip by just entering that ip. If not, you need to implement something to get behind the firewall.
Simple answer; to stream data between a PC and an Android device each residing on different networks you need an intermediate server to pass the data through.
Now, if this just a small app that you are doing for your own purpose I suggest using the free version of Firebase (see https://www.firebase.com/). Their sample application that you'll find there, a simple chat service, does pretty much exactly what you need. Simply let the application on your PC (preferably a web app) read the "messages" that you send from your Android device.

Sharing Files Between Windows and Android over WiFi

Is there a way ( protocol ?) to share & exchange files between pc with Windows os and a mobile phone with Android os over WiFi ?
For an Ad Hoc Android to PC connection (Per the source below):
Connect your computer with virtual hotspot created by Android device.
Install any FTP Server app on Android device. It'll NOT give you IP of device for sure.
In your computer, find IP of Default Gateway of Wi-Fi network of Step 1 (In Windows, you can use ipconfig cmd command). Its the IP of your device.
Use any FTP Client software on computer. Use ftp://IP:Port (Port is generally configurable in FTP server app). Enter username & password configured in FTP Server app. Done!
Then they said "After some testing with different settings I got it to work flawlessly, thank you very much. For anyone else looking to do this: I used Android Wifi Tether to start the network using Softap mode, connected to it with the computer, started an FTP server (some server apps might need you to enable 3G mode, even though 3G data isn't actually used, you can turn data connections off if you're paranoid."
Source
For Internet Based Connections:
You may simply want to transfer the files to a hosted server with push notifications to "pull" down the files to the various devices.
Scope this out: http://www.eckstreme.net/
The coder of that app may be willing to help you get off to a better start, email him.
Here are the steps:
Connect your pc and android device to the same Wifi Network. This can be an ad-hoc network created on the android device or your home/work wifi network.
To create an ad-hoc network on your device go to Settings->More (under wireless networks)->Tethering & portable hotspot and tick the portable wifi hostspot option.
Install a FTP server app like https://play.google.com/store/apps/details?id=com.medhaapps.wififtpserver from android marketplace.
Start the app on the device and connect to the URL provided by the app from PC.
Transfer files to/from device from/to PC

WiFi-Direct communication between Mac/Windows and Android

Is it possible to let an Android (>4.0) device establish a WiFi-Direct connection with a Mac OS or Windows device?
According to the Wifi-Direct Docs the protocol allows:
Android 4.0 (API level 14) or later devices with the appropriate hardware to connect directly to each other via Wi-Fi
It doesn't look like Google provides this functionality via the API. Although WiFi-Direct isn't a proprietary protocol and could be implemented for any platform. There are a few posts around the web of people trying to get Wifi-Direct to work under windows:
Broadcast message from Desktop PC to Android Device using WIFI connectivity
https://superuser.com/questions/417888/how-do-i-connect-a-laptop-running-windows-7-to-an-android-phone-using-wifi-direct
http://www.intel.com/content/www/us/en/wireless-products/my-wifi-technology.html
http://androidforums.com/android-lounge/552970-howto-wifi-direct-use-your-laptop-desktop-softap-android-reverse-tethering.html
All you need is to use java.net.Socket. Depends on what do you mean by establish direct connection. TCP connection is established when on destination device (windows or mac) you open listening socket by ServerSocket. On other device you can use Socket with destination address. Of course, windows or mac box will propably have to open that port in firewall.
I guess what you actually need to know is how to get name of target computer or how to discover computers on local network. Unfortunately, it does not depend on android version I think. You should check http://en.wikipedia.org/wiki/Zero_configuration_networking about some hints. I fear there might be problem in need to open privileged port on android, as normally you have to be root for that. And that would require rooted android.
Of course you should specify what do you intend with that direct connection and what software do you need. If both ends have your application, you can just open any not allocated and unpriviledged port on android. Use UDP to broadcast periodically name of android device (propably ask user to enter name of his device). Use multicast to send requests, and receive replies the same way. Multicast sending and receiving would require your application on android and on windows and on mac also. Now you can read from multicast application what type of machine it is, and what local port it left open for your direct connection. From source of udp message you know where to connect.
You may use some framework to speed things up. All this require some knowledge about networking, but I don't know simpler and well working solution. Unless you provide details about what is your direct connection to do.

TCP connection from phone to debugging host

I'm developing client/server software for Android.
While connected to the phone via USB debugging, I'd like to access the webserver I'm running on my developement PC - using the USB connection.
Is that possible and if so, how ?
I stumbled upon the answer after a night sleep.
Enabling USB tethering on my phone (N1, 2.2.1) gives it and the host computer an IP address. The phone can communicate with my web server running on my developement machine!
(Chris, the rumors are right)
Just make sure your web server is listening on that IP address. For apache, use the line
Listen 80
or
Listen x.x.x.x:80
(x.x.x.x being address of your android tunnel)
The easiest way to do it is via wireless. If you don't have wireless, I'd say bite the bullet and get it, it's going to be a necessity for testing anyway :)
Typically the USB only supports connections from the development machine to the phone (via adb port forwards) and not the other way around. Of course once a connection is created data can move bidirectionally. One could use this to build a tunneling proxy web proxy (one connection in from the development machine to a daemon running on the phone, outbound connections from the phone then tunnel through this)
I have heard rumors though that what you want to do - often called reverse tethering - may be supported in some more recent devices.
Kevin's wifi suggestion may be the simplest with a real device.
On the other hand, unlike typical phones, the android emulator can directly access the development machine's loopback interface at an alias address given in the documentation.

Categories

Resources