Connect Android Device to a localhost on Windows - android

I tried to connect to a localhost on my windows PC from Android devices but it doesn't work at all.
I host it using ISS Express (installed with VS2013)
I tried http://10.0.2.2:59087 and my ip http://192.168.43.83:59087
I connected them using an AP from my Android and from the router
I also disabled windows firewall
All this configurations but nothing is changed
What is the problem?!!!

you HAVE to be in the same network for this to work, that's all, you don't have to go through all that trouble, if you are in the same network, then you can access your ip easily just make sure your windows side server (eg: localhost:8080) is active and accessible

Related

Android browser doesn't see Fiddler proxy

I have a problem when connecting Fiddler and my mobile with Android 9.
I installed Fiddler (tried on Windows 7 and Windows 10) and configured it with "allow remote connections". Then configured Android device from
https://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/ConfigureForAndroid
Both the computer and the device are at the same network with router (wifi and cable for the computer). I use VPN. Router passes VPN connections (I see necessary sites on the computer and the device with strongSwan).
Restarted Fiddler and reconnected wifi on the device. Wifi icon is "Connected".
Through VPN I get a special part of the site configured in hosts.
Like 10.10.10.10 firstsite.com www.firstsite.com secondsite.com
On Windows when I enter firstsite.com it goes to 10.10.10.10. This is correct.
On Android when I enter firstsite.com it goes to firstsite.com, but I need it to go to 10.10.10.10.
Fiddler folder is in firewall exceptions. IP is static.
Please, help me. I tried many things found in Google but without success.
Works on Windows 10. Very wild thing: when setting wifi it is necessary to delete wifi and then setup proxy and port then password and then connect. Connect vpn on the computer and the device. If no luck restart computer, fiddler and the device (don't forget to turn on vpn). After it I was able to open the necessary site 10.10.10.10 on Android 9 pie.

Connecting mobile phone to a computer localhost

I'm developing a web application (I'm using MacOs) and I would like to see the screens on my android mobile device. Although both devices connected the same network I couldn't connect computer's IP address and local port on my phone. I'm thinking of this issue is showing up by MacOs. Because when I run same project in to Windows machine I can connect to the IP address with my phone. I've tried a couple of things but I couldn't solve the issue. What should I do be able to connect my phone to the computer's IP address ?
Go check how can you create a server with a "real world" link using ngrok (https://ngrok.com).
I assume Nodejs application only bind to your local (MacOS) and only can access from your laptop. The option is using Nginx or Ngrok to open application to LAN or world.
If you want allow other devices from LAN to connect to your Mac, you can go to System Preferences > Security & Privacy > Firewall then Off.

Access the localhost via android device Easyphp

I need to access a localhost on easyphp via a physical android device, but I'm not succeeding.
I tried to disable firewalls, both private and public, but nothing.
I tried using the ipv4 of the wireless wifi lan card, but nothing.
I've tried various solutions on stackoverflow, but nothing seems to work.
Os pc: windows 8.1
port localhost: 8080
Nodejs
I'm doing the tests from the mozilla browser of the android device.
Can it be a problem?
What can I do?
Use a fixed ip of server machine rather then local host.
and your mobile device and server machine having same network, like local network.
like:
your.ip.address:port/yourpath
try this method -> https://stackoverflow.com/a/56884341/8168420
I use localhost:4880 in your Case just put the "local address" -> localhost:8080 in the port forward and the Device port will be any port of your choice e.g (8888)

Connect to the PC's local host through usb cable on android device

I'm debuging an android application using my android smartphone (Sony Experia) and I need to connect to the computer's local host through the android app I'm developing. I tried several methods (USB tethering, Wifi hotspot) but I couldn't achieve it. Please support me with a solution. I know that simply 10.0.2.2 is working well on the android AVD but I've no idea about real devices.
I'm using Microsoft Internet Information Services (IIS) as my server and the web application is also running well. I don't know whether the firewall is blocking the port or not.
This should work:
Unplug all the network cables on the computer and turn off your wifi.
Turn off the wifi on your Xperia.
Connect your Xperia to your computer via USB Turn on "USB Tethering" in the android menu. (Under networks-> more...-> Tethering and portable hotspot")
Get the IP of your computer that has been assigned by the USB
tether cable. (open command prompt and type "ipconfig" then look
for the IP that the USB network adapter has assigned, It is Under 'Ethernet Adapter Local Area Connection' title. The Value for the IPv4 address is the One you need.)
Open a browser on the PC using the IP address found instead of
localhost to test. i.e.
http://192.168.1.1/myWebSite
Open a browser on the android and it should work.
If it is working on your PC but not in your device, You have to allow your http through firewall.
Follow How to enable sharing of web site on localhost? to do it.

android connect to PC's localhost when debugger on mobile device

I want to debug my android application, I connect the android device to my PC using the USB cable. In my application there is a button to connect with localhost, ip for localhost is 10.0.2.2 and the port is 8080, I have read that when debugging on mobile, the ip 10.0.2.2 is the localhost for android device and not for my PC, so what changes should I make to the ip instead of 10.0.2.2? or do I have to make another change?
In this case my android device is sony ericsson xperia arc s.
Google has added support in Chrome 29 and higher to use reverse port forwarding to access a website hosted on your local development machine through the USB cable on Chrome for Android. Setup instructions can be found at the following URL:
Android Remote Debugging - Reverse Port Forwarding
Tools for Web Developers - Access Local Servers
As of desktop Chrome 30 Reverse Port Forwarding is no longer an experimental feature in Chrome. It can be accessed by typing about:inspect in the address bar of your PC, and by clicking the "Enable port forwarding" check box and clicking the "Configure port forwarding" button located to the top right of the window.
Once that is done, connect your mobile device via USB. Open Chrome on your mobile device to localhost:8000 (or whichever port you have configured on your local server).
The Reverse Port Forwarding functionality will make sure that your Android device now sees your PC's localhost.
As 10.0.2.2 is your system (pc)'s local host address (from emulator only). Actually android doesn't recognized localhost in url. so 10.0.2.2 is for that meant. Also for android device loopback address is 127.0.0.1.
Your url with 10.0.2.2 is correct. Also you can use Static IP of your system.
Just check for
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
in your application's manifest file.
EDIT:
Here you are using port 8080 so, try with adb command on your host machine.
adb forward tcp:8080 tcp:8080
Also please elaborate on this line "i want to debugger my application on my mobile".
Note:
If you are going to test on real device use your Network IP of system (PC).
For that you need to make some changes in your xampp server... Assign 1 static IP address to your system and then you need to put your xampp server in online mode. after that you can use that ip address in your android application instead of 10.0.2.2. Works fine for me as i am using my localhost with my android application.
You can share your Mac's Internet connection over Wi-Fi. Then your Android app can connect to a Servlet running on the Mac with HTTP over Wi-Fi. The steps are:
Run System Preference on Mac
Goto "Sharing" tab
Turn on "Internet Sharing"
Select "Ethernet" in the "Share your connection from" combo
Select "Wi-Fi" in the "To Computers Using" list box
Use "Wi-Fi Options..." button to configure Wi-Fi security. Now your Mac is a Wi-Fi server, and it is sharing its Ethernet Internet connection.
Configure your Android device's Wi-Fi to connect to your Mac (in Settings command)
On your Mac, goto the Network tab in System Preferences, and select Wi-Fi in list to find out the IP address of your Mac on the Wi-Fi network (for me it was 169.254.66.223)
In your Android App you can now connect to the Servlet in your Mac with "http://169.254.66.223:8080/YourServer/YourServlet"
I think you have two options
The first one is using 10.0.2.3 when you use your real android device.it works for me.
Your Second opt is creating hotspot from your pc and connect your android device to the hotspot.
Find the ip address using cmd type "ipconfig" replace localhost with the ip address.
Thanks.

Categories

Resources