Connecting to host from Android via USB - android

Okay so here is the background of this problem. I commute a lot on the train and build a lot of PHP web apps optimized for mobile devices. I would like to develop code on a netbook (Running Ubuntu Server) with no GUI. All development done using Vim directly on the netbook.
I would like to connect up my Nexus 4 to the netbook via USB and "connect" to the netbooks web server in the chrome browser. I can only use USB for this since I won't be having any reliable internet access.
I understand that using adb from the Android SDK, you can forward a port from the netbook to the phone. However, I need to do it the other way around.
For example:
Run a web server on the netbook on port 4000
Connect phone via USB
Somehow forward port 4000 on the phone to port 4000 on the netbook
Open chrome browser on phone and go to localhost:4000.
I am aware of the "reverse port forwarding" method that is described in the Google docs at https://developers.google.com/chrome-developer-tools/docs/remote-debugging. However, this requires an installation of chrome on the netbook. I don't want to have to install an entire GUI just for this.
Update
With regards to the above, I have found https://groups.google.com/a/chromium.org/forum/m/#!topic/chromium-reviews/7mE61hDcFdA. Does this mean I could install Chrome on the netbook (even though I don't have a GUI) and port forward via CLI?

An APP might do the job here. If you know some java you might be able to pull it off. Basicly you tunnel a connection through adb, then use an app as proxy and a small program on the computer. There might be an easier way though

Related

How to mitigate local network problem with Expo

Expo is crashing when using an Android emulator on my Ubuntu machine. So what I want to do is upload the app to my real Android device using Expo. But when I do this using the local wifi network, I get:
Perhaps I should just physically tether my phone to my Ubuntu laptop instead of going through Wifi? What about bluetooth to upload the app to the phone from my Ubuntu machine?
In the tutorial there is an explanation of how to handle this: https://docs.expo.io/get-started/create-a-new-app/
Is the app not loading on your device?
First, make sure that you are on the same wifi network on your computer and your device.
If it still doesn't work, it may be due to the router configuration — this is common for public networks. You can work around this by choosing the "Tunnel" connection type in Expo Dev Tools, then scanning the QR code again.
🐢 Using the "Tunnel" connection type will make app reloads considerably slower than on "LAN" or "Local", so it's best to avoid tunnel when possible. You may want to install a simulator/emulator to speed up development if "Tunnel" is required for accessing your machine from another device on your network.
An aside -- I've opened an issue here to discuss adding an easy and fast way to connect to your device under these circumstances.

I'm using xampp for local server and I want to test my locally hosted site to android mobile. How would I do that

I'm using xampp for local server in a 64-bit system. I want to test my locally hosted site to android mobile device to check the responsiveness without hosting it to any web server. How would I do that. Please answer soon
Make sure the Apache module in XAMPP is started up and your android phone is connected to your router(assuming that you are on a wireless network). Find the local IP address of the computer hosting the server. Mine, for example, is 192.168.1.142. This may or may not be similar to yours. Type that IP address into the phone's URL bar. You may need to append the port number to that too, depending on the server settings. For example, if XAMPP is running Apache on port 8080: 192.168.1.142:8080.
To obtain your local IP, it slightly varies depending on the Operating system.
For windows, go to command prompt and do the command ipconfig, it should appear as an entry there.
For linux-based systems, I believe you use the command ifconfig in terminal.
If you do not have a wireless access point, it may not be possible to visit it as the phone naturally does not have an ethernet port.
I think that's not possible. However you could find a free web host to try that out. Here is one:
http://www.host-ed.net
If you really don't want to use a web host, then try downloading the files to your phone/tablet and running them directly from phone/tablet. That will work if you have just plain html/php files. Otherwise browse google play to find a app that can run those files.
This was not available in 2014, but now you can get just a simple browser extension for testing your responsive design.
For Chrome you have e.g. 'Mobile simulator - responsive testing tool'
Simple free tool

Android App and Communications via USB

Ok, so I have researched this somewhat and am not encouraged, but I'm going to ask anyway, and be specific about what I'm trying to do. Maybe it will help!
I have a custom board with DaVinci processor with USB 2.0 OTG controller on it. I have it configured as a host with an attached hub and various peripherals. This processor runs Monta Vista Linux (MVL) 4.0 with 2.6.18 based kernel. This custom board some video processing and streaming.
I also have a Moto Droid. I can attach the phone as a USB device to my DaVinci system and MVL will enumerate the phone, but obviously doesn't know which driver to use. That I can fix.
So what I would ideally like to do is be able to have a data connection between my board and the phone, and use the phone with a custom app, as a configuration tool (initially). I'm thinking RNDIS would be wonderful, but I don't know if Android supports that on the USB port. Then my custom app would establish a connection over the USB to a server on my custom board.
Can anyone attest to what Android DOES support over USB, besides adb and flash file system?
Any other suggestions are welcome, although please don't tell me "Bluetooth", it doesn't have bandwidth for video, which is a future goal.
Thanks!
For small amounts of data, you could look at Working Android with Arduino, which points at Microbridge (http://code.google.com/p/microbridge/) or you could also look at IOIO (http://ytai-mer.blogspot.com/2011/04/meet-ioio-io-for-android.html).
For things like video, adb port forward (http://developer.android.com/guide/developing/tools/adb.html#forwardports) could be you friend (assuming you have the networking stack on MVL all setup and adb configured). You can basically set up port tunnels for TCP over USB and shift reasonably large amounts of data over the link. One end of the connection (probably the android device) runs a TCP/HTTP server, and the custom board opens connections to communicate. This works reasonably well, you set up a thread running adb devices to detect the plugging in of the Droid device, run adb port forward to set up the port forward, then open your sockets and you're good to go.
Is using 802.11 an option for you on the Davinci board? E.g. either via a Wifi USB dongle or through wired ethernet to an AP? If so, that would seem to be an easier route to communicate with Android than trying to go through USB. Or are your video resolution and compression requirements more than what you'd expect to realistically get through 802.11?

Desktop PC and Android interface

I'm thinking to develop a PC desktop program to get application setting from android phone, install/uninstall apk application, sync photos/videos/music and display a web content.
Initial thought is to use .Net to write desktop program and shell ADB tool to do installation and file copy on android phone. However seems like advanced feature of ADB only works on a rooted android phone.
Is there an communication interface between windows and android system? Based on an app called "Android Manager" by Mobile Action, it seems that it can pull out what apps are installed on the phone but seems like this cannot be done by ADB alone without root access.
I would like to do the transfer of information using USB cable. Any thoughts where to research on? Thanks much
If you want to use the USB cable you can only use ADB, but you can use ADB to set up a socket between your pc and the mobile device. Both sides can then connect to this socket and use it to transmit data.

Using My Android as a USB Device

I've been able to find a few posts on StackOverflow about how to control USB devices using an Android phone -- which I understand is impossible (The Android being a USB device and all.)
However, I would be perfectly happy to set up my application to communicate with the other computer (a Linux host) as a USB device. (Like a really expensive mouse...)
Does anybody have information about how to set up an Android app/phone to use the USB connection and exchange data with a host computer. Obviously, it already works at some level -- it's how Eclipse and Android SDK/debugger do what they do, but I'm still looking for some way to do this in an application.
(My current phone, BTW, is a Droid Incredible.)
Thanks,
R.
Basically you'd need to install the USB device driver and the ADB toolsuite from the SDK, either that or reverse engineer their functionality and build it into something else.
Then you enable USB debugging on the phone.
And then you can do something like an adb port forward to allow an application on the pc to connect to a network socket listener on the phone. Note that connections cannot be made in the other direction, but once a connection is made it is bidirectional.
If your version of android supports tethering over USB, you could also leverage that to implicitly create a network between the PC and the phone, at which point you can make connections in either direction. Just make sure nothing starts accidentally pumping lots of data through the phone's mobile network!
(Many android phones actually can experimentally function as USB hosts, but you have to compile new drivers into the kernel, install the new version, and make up a cable to provide USB power to the device as the phone cannot. Also you lose the ADB over USB channel which makes debugging a pain)

Categories

Resources