1

I try to test my project with wifi connection : I use genymotion emulator 4.2.2 the emulator detect the wifi/3g connection but in my project i can't connect to the localhost

it is necessary to change the code or do any configuration on the emulator?

code :

public class ConnectionDetector {
    private Context _context;

    public ConnectionDetector(Context context){
        this._context = context;
}
    /**
     * Checking for all possible internet providers
     * **/
    public boolean isConnectingToInternet(){
        ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
          if (connectivity != null)
          {
              NetworkInfo[] info = connectivity.getAllNetworkInfo();
              if (info != null)
                  for (int i = 0; i < info.length; i++)
                      if (info[i].getState() == NetworkInfo.State.CONNECTED)
                      {
                          return true;
                      }

          }
          return false;
    }
}

in HomeFragment :

ConnectionDetector cd;
// Check if Internet present
    if (!cd.isConnectingToInternet()) {
        // Internet Connection is not present
        alert.showAlertDialog(RegisterActivity.this,
                "Internet Connection Error",
                "Please connect to working Internet connection", false);
        // stop executing code by return
        return;
    }
user3049804
  • 41
  • 2
  • 7

1 Answers1

1

Genymotion's emulator works using Oracle VM VirtualBox, VirtualBox install a driver for a direct connection between your computer internet connection and the emulator's. Dis you try accessing a webpage from android webbrowser inside the emulator? If you can acces the webpage then maybe there is something wrong inside your app but, if you cant, i would advise on reinstallling VM virtualbox or directly asking for genymotion support

nunoh123
  • 1,087
  • 1
  • 10
  • 17