Question

I want to download some data if user is currently on a wifi connection but if user is connected using cellular data (e.g. 3G) I dont want to do anything to prevent data charges for the user.

In order to do this, I need to know current connection type. Is there any API that would give me this information? (This is a native application.)

Thanks.

Was it helpful?

Solution

Perhaps you will find this article and sample-code useful.

Another option to verify WLAN-status would be by reading the following registry-value:

HKEY_LOCAL_MACHINE\System\State\Hardware\Wifi

at least according to this post (which I guess you can easily adapt to native code). If WLAN is on, I guess you can safely let the user download data.

Edit: the values obtained seem to correspond to the following WLAN-status:

0 - powered off

1 or 5 - ready

11 or 15 - connecting

19 or 23 - connected

I am not 100% sure if when WLAN is connected, any other data-services such as 3G will not be used. Maybe this depends on the connection-settings. However, when I am using my device, I noted that if WLAN is connected, it "takes command". If you have the possibility, you should verify this using different devices, perhaps with different operators.

Good luck.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top