I'm trying to hit a server using an android app which I developed. Though I'm able to access different web sites using android browser present in emulator, my app is not hitting the server.
This is code to check availability of internet:
ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
final NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if(mWifi.isConnected()){
}
else{
Toast toast = Toast.makeText(getApplicationContext(), "Please check internet connection!!", Toast.LENGTH_SHORT);
LinearLayout toastLayout = (LinearLayout) toast.getView();
TextView toastTV = (TextView) toastLayout.getChildAt(0);
toastTV.setTextSize(30);
toast.show();
toast.setGravity(Gravity.CENTER, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
}
Toast present in else block is being showed.
These are permissions requested in androidmanifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
This app works fine on real device, but I'm unable to test with emulator. Please throw some light.
There are no proxy settings being used in my network.
Thanks.