I am developing an android application in which i have to connect my android application with local host.I have done r and d,and implemented lots of codes.But didnot get success.Here is my code for establishing connection.Its showing in ddms connection to localhost refused
http://pastebin.com/wVmzdQvA
when i run the url on browser its opening.Dont know where actually the problem is
If anyone can guide me
Regards
Tushar
Your problem is simple when you think about it.
localhost on your laptop, and localhost on your android phone are not the same.
You are telling your phone to connect to phpmyadmin running on the phone... not on your laptop.
You need to have an external ip address for your laptop, and connect to this.
Try http://www.whatismyip.com or ifconfig to find out an ip address your phone can use to connect.
Lets say that within your local network you have the ip 192.168.1.14, then you should be able to connect by replacing 127.0.0.1 with 192.168.1.14.
Related
I'm developing an android app that connect with a restful web service which is on my tomcat local server.
The app works well on the emulator, however, it doesn't work on my real mobile.
I use the IP from ipconfig, and both my laptop and my phone connected to the same Wi-Fi.
I tried to call the web service from the mobile browser but still, it doesn't see my localhost :(!
it shows me :
This site cannot be reached.
I searched a lot and all the solutions say that I have to connect both to the same Wi-Fi network and to use the IP from ipconfig command, which I did!
How can I fix this?
PS: I'm using 9090 as my port number, I don't know if that a reason?
Thank you.
I am making an application that needs to access the server database.
But since its still in the early stage, I have to delete the database quite often which is a problem because its used for other web applications too.
So I was thinking if I could test my application against my localhost database it would make it much easier for me.
I tried a few solutions on stack overflow but they didn't work for me so here is my problem.
I have lamp setup on my system.
In my browser, I can access localhost using 127.0.0.1 but if I try the same thing on my phone's browser it shows that the connection was refused.
Both my laptop and phone are connected to the same wifi network.
Is there some permission I have to provide that I am not aware of?
your 127.0.0.1 refers to your desktop.
Find out the local ip of your desktop (example 192.168.0.2) and then use that ip on your mobile browser
You should try to access to your laptop by using its IP address.
If your laptop is running on Windows, run the command ipconfig from a Command Prompt Window and then use the ip address the command returned on your phone's browser.
This should work.
Many people ask about "How get the connect from a emulator to localhost". I am asking about a reverse issue. I created a tiny http server in android app. I know his ip address and want to connect from my chrome browser to the app. If i use my a phone it is no problem, because app use "outer" ip, but in local net wifi. When i use a emulator on a development machine and open in browser ip 10.0.2.15 then can not get access to app in emulator. I tryed any ways - loopback, forward ... all is not working.
I have a Tomcat server running on Localhost. My app can access it in the emulator using 10.0.0.2:8080. But when I connect a device it can't access the server.
I've seen some similar questions but couldn't get this working. can someone give me the steps on what to do?
we use 10.0.2.2:8081 because 127.0.0.1 is reserved for the emulator, however, when you need to try the application through a real device you need to change the URL to your PC IP
go to CMD and run ipconfig, look for IPv4 address, this IP you will use it..
add it to the URL for example: http://192.somethin.somthin.somthing:8081/the-location.php
P.S: you should set your firewall off and turn off any antivirus
The device may not be on the same network as the Tomcat server. Does your network provide VPN access? If so, try installing an Android VPN client (Junos Pulse is a good free one). Connect your device to VPN and try again.
10.0.0.2 looks like an internal address. The emulator is likely able to connect because the machine on which it is running is connected to the network. The actual device needs a direct connection as well. VPN should solve that.
I made an app that connects to a php file. The code is working using the AVD without a problem. Now when I tried the app in my android device it force closes. My android device is connected through a wifi network. I'm using wamp server on windows 7.
I have pinpointed the problem but I cannot resolve it. I'm hoping one of you good guys can help me.
This is my culprit (192.168.1.100 is the machines IP):
private static String url_all_products = "http://192.168.1.100/android_connect/get_all_products.php";
How can this be solved? 100% working in AVD but won't work in actual android device.
#droidH if you working on local server change your url to 10.0.2.2 to your IP address
go to this link it works
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
You need to check two things :
Your external IP address i.e if you are using windows use command
"ipconfig" and get IPv4 address.
Check you permissions in AndroidManifest :
uses-permission android:name="android.permission.INTERNET"
Also check : https://stackoverflow.com/a/16510143/644011
Do this:
first, put both your android device and your computer into the same network as described here
then, make your device connect directly to your computer via its IP in that network (find the IP as here)
Try to connect your mobile to the same network as your computer.
I used virtual router to make my mobile in same network as my laptop
Then use ip address of your computer to access your computer web server from your mobile.