📜  检查互联网 android - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:46.262000             🧑  作者: Mango

代码示例4
private boolean isNetworkConnected() {
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

    return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected();
}