Reputation: 1050
I want to make http connection which ensures that it is done through wifi only,so that I can not be charged for the transfer of packet from GPRS or 3G network.
It means what ever the connection available I can use only wifi that I want to ensure through Application itself..
All help is appreciated.
Upvotes: 1
Views: 815
Reputation: 14895
You can use connectivitymanager for this.
ConnectivityManager cm = (ConnectivityManager)Context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if(ni == null)
//no connectivity, abort
if(ni.getType() == ConnectivityManager.TYPE_WIFI || ni.getType() == ConnectivityManager.TYPE_WIMAX) {
//connected via wifi/wimax
//so transfer the data
}
Upvotes: 2