Reputation: 3380
Thanks for previous replies,
I tried to check the data connection through code, I used
final ConnectivityManager connMgr = (ConnectivityManager) this
.getSystemService(Context.CONNECTIVITY_SERVICE);
final android.net.NetworkInfo wifi = connMgr
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
final android.net.NetworkInfo mobile = connMgr
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (wifi.isAvailable()) {
return true;
} else if (mobile.isAvailable()) {
/*
* check.setImageResource(R.drawable.tick);
* check.setVisibility(View.VISIBLE); noInterntet.setText("");
*/
return true;
} else {
return false;
}
But this code check the data availability from android version 1.6, when i run this code in 1.5, it never check the data availability, i always return true even i disabled GPRS and Wifi. is there anything other than this to check the data availability. Dont know where i made mistake.
Upvotes: 0
Views: 2737
Reputation: 4928
Are you sure you want 'isAvailable' rather than 'isConnected'? You could also query the enable state of the devices, i.e. WifiManager.isWifiEnabled()
I suspect that your 1.5 device simply misreports the availablity state. I would question the need to work on 1.5 since there are very few real world devices using it. I can only think of the years-old G1 and Magic phones for which 1.6 updates were made available.
Upvotes: 1