检测 Android 上是否有 Internet 连接可用

NetworkInfo ni = new NetworkInfo();
if (!ni.isAvailable()) {
    // do something
}
The constructor NetworkInfo is not visible.

答案