0

You might know the open Wi-Fi networks where you have to enter a password to use the internet. These are often in an airport. If you have enabled Wi-Fi your device connects to this network. Now I would like to send data with an app. So I have to check if there is a Wi-Fi network which I can use to send the data. I guess that these open networks at the airport do not allow to send data. If there is no network the device would connect via mobile data. So how can I check if it is possible to send data via Wi-Fi?

4

1 回答 1

1

在我看来,您只需要检查您是否有 Wi-Fi,因为如果您有 Wi-Fi,您可以通过它发送数据。你像这样检查它:

ConnectivityManager connManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo wifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

if (wifi.isConnected())
{
    // send your data
}
于 2013-07-03T18:51:31.843 回答