Thursday, July 05, 2012

Access localhost/Server on Android device over wifi


Recently in one of my android project I have used XAMPP for database. For accessing  database/localhost/server from my application I have use ip address 10.0.2.2 . That is the way for getting  localhost from android device. But when I have installed that application in my real device that was unable to get the server  . How that will get the server? I have use 10.0.2.2 for http connection . So, getting the server we have to make a connection between android device and our server location. We can do it by connecting with connectify software that will help us to communication device with our server. And in this time have to use in this time the ip address create by WIFI connection as we are creating connection with the server by using wifi.

In this situation I have used cracked "Connectify" so that my android device have the access of my laptop
local network access. In the lite version of connectify you won't get the options for allowing "Local Network Access " .




After establishing connection have to go command prompt . Write "ipconfig" to get the ipv4 address.
In the command prompt which ip address is given , you have you use that ip address in your application for getting the server. (Below red marked line : you have to use that ip address)



Before editing your code you can also check from your android device is it working or not . For that you have to go browser then write the ip address in the url then we will get the localhost.

















2 comments:

  1. Nice one...Useful tutorial? dude can u do one favor for me i felt some thing mess it up i am unable to understand here can u pls explain elaborately or can u have any example like this which u have explained elaborately???

    ReplyDelete
  2. tqvm for this good post.. u help a lot

    ReplyDelete