I want to test my app on a android device, I have a local webservice (ASP.net) that is hosted in my laptop in local, when I plug my device, the app works in it but it cannot receive data from my local webservice, how can I get the data sent to the device just like in the emulator
PS: the app works properly in the emulator.
thank you
The emulator uses your laptop's network interfaces, hence it can access webservice directly. Your device needs to connect to your laptop via its own connectivity options (celluar network, WiFi, possibly bluetooth).
I have a few ideas how to get there:
If you have got a WiFi router and both your laptop and phone connect to it - that's pretty straightforward: just expose webservice to address that can be seen within network and use it on your phone.
If you've got an external IP - just use that address when phone is connected to network.
Set up a WiFi access point on your laptop and connect your device with it
Check these URLs how to set up a hosted network (hotspot) on Windows 7:
Hosted network documentation in MSDN
Hosted network tutorial
You might try Bluetooth and PAN.
Related
I have a webserver that is running on a network that is not connected to the internet.
The webserver serves up a website.
When I connect an android phone to it, I am able to run the website that is on the webserver
But with certain phones that are running Android 11 I need to disable the mobile data on the phone before it will try to access the website over wifi. It seems the phone will not try to request the url on the wifi network because it doesn't have internet, so it defaults to using the 4G/5G Cellular internet connection. This is too bad, because I would like the phone to use the wifi connection.
I would think that perhaops I could "force" the phone to use the wifi connection by typing the IP address in the browser's URL bar (eg. http://192.168.211.1/index.php), however it seems that even with the "local ip" it will still try to use the 4G/5G network instead of the "offline wifi" network.
The only workaround I have found is to disable moblie data on the phone, but this is not ideal.
I would think that some IoT devices would have an offline webserver used for configuation/control.
Is there a certain port or settings I should be using?
Is there a designated port that the browser/OS would expect to be on an offline network?
Basically, how can I make the phone use the wifi, even though the wifi is not connected to the internet?
Thanks so much for any pointers!
I am using the NanoHttpd library to set up a server. It is currently serving a 'Hello World' HTML page.
It is accessible from the browser of the phone on which it is deployed but not on other phones or laptops on the same WiFi.
For example, http://10.54.92.228:8080 is accessible to the browser of the phone on which the server is deployed. But, is inaccessible to other devices over the network. Is there any way to enable incoming connections ?
I am working on a similar project, I have to host files over WIFI on an android device which is accessible to anyone on the same WIFI network.
The web server is working as I want.
I think the problem is with your IP-Address of the server.
For a WIFI network, the network should be in the range of 192.168.137.XXX.
What you are inputting is the global ip of the device on which your server is.
Check you local ip, and enter it with the port number and it will work.
Ping me if you need any help.
I am programming an Android app which connects to a TCP server running on my computer using sockets. This works perfectly fine as long as both my computer and my smartphone are connected to the Wi-Fi of my router.
I want it to also work when my computer and my phone are not connected to the Wi-Fi. Therefore I configured a Wi-Fi hotspot using hosted network on my computer. My smartphone recognizes the Wi-Fi and is able to connect to it. But now my app can't connect to the server running on my PC although I changed the code to the new IP that I got by using ipconfig on my PC.
I downloaded an app named "Fing" from the Google play store. The app shows all devices in a network. It does show my computer under the right IP address. I don't understand why my app can't connect to the server running on the PC.
On the one hand, I don't think that the problem is in the app's code, because it works on the router's Wi-Fi network. On the other hand, I doesn't seem to be a setup mistake either, because Fing is detecting my PC.
Do you have any ideas what the problem might be, or any other solution for my needs?
I actually wrote the TCP server myself using c#. I configured the Server to listen to all of my computers networkinterfaces usingIPAdress.IPv6Any. I also did configure it as dual mode socket so it can accept ipv4 and ipv6 connections. I will post the code when i am back home. So the TCP server also looks ok to me.
I need to send an image file from the mobile to the server(where the server will save it to the hard disk). I have wrote both the android mobile part and the server side. I need to test the code before deploying to the server. Will the code work if I connect the mobile to the WI-Fi network through which I can have a LAN connection to the system? Is there any way I can test the code with out using a WI-Fi connection(ie Connecting phone to the system via the usb cable and then forming a LAN or something)? Please voice your valuable opinion in these stuff.
When I was testing my server-side I didn't find any other way rather than connecting via wifi, this way it was working just fine (in your code you need to use ipv4, not localhost, just as reminder). I'm not good with network stuff, but I don't think it's possible using usb to create some kind of LAN.
Have u tried from emulator? How to connect to my http://localhost web server from Android Emulator in Eclipse
First, my goal is to access from chrome on my HTC one X, to my local server on my laptop.
The local server works (wamp), and runs from 127.0.0.1.
I can't depend on outer network, thus I want to create a local wifi network.
Currently I turned on Wi-Fi Hotspot on my phone. The laptop successfully connected to the network, and phone actually recognized it.
The IP of the laptop is 192.168.1.150 (I found this both from the laptop and the phone).
My problem is that in the computer, when I try to access 192.168.1.150:80 I get 403 Forbidden, and I get nothing on my phone (I even tried to send packets with no success).
Finally found the solution!
http://www.mobitechie.com/android-2/how-to-access-localhost-on-android-over-wifi/
This tutorial explained each and every problem I had (how to fix 403 error and open the relevant port in the firewall).