tags:

views:

56

answers:

1

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.

+1  A: 

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
}

bhups
thanks for your time..through this i can come to know if wifi or wimax is available or not? There might be then case in which my default connection in my phone is GPRS or 3G, I want to explicitely make sure that i m using wifi only not from settings of the phone but from application itself..Thanks
Rakesh Gondaliya