tags:

views:

69

answers:

2

Hi, I am trying to determine if my current connection state is WIFI or Cell network (3g/2g... etc) I am using SDK 1.5.

Tried couple of technics not realy working.

Any working suggestions?

Thanks,

ray.

+1  A: 

I think NetworkInfo has a field for this.

Check out getTypeName() Return a human-readable name describe the type of the network, for example "WIFI" or "MOBILE", go check out here

Pentium10
+1  A: 

i forget the sdk version ,if you look for"WIFI" or "MOBILE", you may ues ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

//mobile State mobile = conMan.getNetworkInfo(0).getState();

//wifi State wifi = conMan.getNetworkInfo(1).getState();

if (mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING) { //mobile } else if (wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING) { //wifi }

pengwang
i tried that once, and i got mobile == NetworkInfo.State.CONNECTED as true both cases(wifi and without wifi)is that possible?
rayman