Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/* 
 * Copyright 2012 Share.Ltd  All rights reserved.
 * Share.Ltd PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * 
 * @ApplicationUtil.java - 2013-2-4 5:15:28 - anonymous
 */

import android.content.Context;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public final static boolean isNetWorkConnected(Context ctx) {
        ConnectivityManager manager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo network = manager.getActiveNetworkInfo();
        if (network != null && network.isConnected()) {
            if (network.getState() == NetworkInfo.State.CONNECTED) {
                return true;
            }
        }
        return false;
    }
}