<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
public boolean isNetworkAvailable() { ConnectivityManager cm=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); // if no network is available networkInfo will be null, otherwise check if we are connected if (networkInfo != null && networkInfo.isConnected()) return true; return false; }
沒有留言:
張貼留言