List of usage examples for android.net NetworkInfo isConnectedOrConnecting
@Deprecated public boolean isConnectedOrConnecting()
From source file:org.onebusaway.android.util.UIUtils.java
public static boolean isConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return (activeNetwork != null) && activeNetwork.isConnectedOrConnecting(); }
From source file:com.vadimfrolov.duorem.FragmentNet.java
@Override public void onResume() { super.onResume(); // Listening for network events IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); getActivity().registerReceiver(mNetworkReceiver, filter); // check connection right away NetworkInfo ni = mConnMgr.getActiveNetworkInfo(); mIsConnected = ni != null && ni.isConnectedOrConnecting(); }
From source file:com.joravasal.comicagg.ComicDetailActivity.java
@Override public boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { return true; }/*from w w w .ja va 2s .c o m*/ return false; }
From source file:is.heklapunch.sendjson.SendJSON.java
public boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) this._caller.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { return true; }/*from w w w . j ava 2s. co m*/ return false; }
From source file:edu.berkeley.boinc.attach.ManualUrlInputFragment.java
private Boolean checkDeviceOnline() { ConnectivityManager connectivityManager = (ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); Boolean online = activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting(); if (!online) { Toast toast = Toast.makeText(getActivity(), R.string.attachproject_list_no_internet, Toast.LENGTH_SHORT);//www. j a v a2 s . c o m toast.show(); if (Logging.DEBUG) Log.d(Logging.TAG, "ManualUrlInputFragment not online, stop!"); } return online; }
From source file:com.example.rnice01.pitected2.RegistrationIntentService.java
protected boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnectedOrConnecting(); }
From source file:free.yhc.feeder.model.Utils.java
/** * Is any available active network at this device? * @return/* w w w .j a v a2 s .co m*/ */ public static boolean isNetworkAvailable() { ConnectivityManager cm = (ConnectivityManager) Environ.getAppContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni; if (isPrefUseWifiOnly()) ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); else ni = cm.getActiveNetworkInfo(); if (null != ni) return ni.isConnectedOrConnecting(); else return false; }
From source file:org.wso2.iot.agent.services.AgentStartupReceiver.java
private boolean isNetworkConnected(Context context, Intent intent) { if (intent.getExtras() != null) { final ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo ni = connectivityManager.getActiveNetworkInfo(); if (ni != null && ni.isConnectedOrConnecting()) { if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Network " + ni.getTypeName() + " connected"); }/*from ww w . j a va2 s . c o m*/ return true; } else if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, Boolean.FALSE)) { Log.i(TAG, "There's no network connectivity"); } } return false; }
From source file:com.ph1ash.dexter.beeplepaper.BeeplePaperService.java
private boolean isNetworkAvailable() { ConnectivityManager cm = (ConnectivityManager) getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return (activeNetwork != null && activeNetwork.isConnectedOrConnecting()); }