Question

I´m trying to get a JSON-Format text from a website. It works perfectly on my real smartphone, but it don´t works in the Android Emulator(4.0.3). Checking Internet Connection is positive with this one:

ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Activity.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isConnected())
            return true;
        else
            return false;

That gives me empty result in my emulator, but I get something in my phone:

HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResponse = httpclient.execute(new HttpGet(url));

    inputStream = httpResponse.getEntity().getContent();
        if (inputStream != null)
            result = convertInputStreamToString(inputStream);
Was it helpful?

Solution

Read through this, it should solve your problem:

http://www.gitshah.com/2011/02/android-fixing-no-internet-connection.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top