List of usage examples for android.net NetworkInfo isRoaming
@Deprecated public boolean isRoaming()
From source file:de.micmun.android.workdaystarget.DaysLeftService.java
/** * Returns <code>true</code>, if you are connected to the internet. * * @return <code>true</code>, if connected to the internet. *//*from w w w. j av a 2 s .co m*/ private boolean isOnline() { boolean ret = false; ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.isConnected() && !ni.isRoaming()) ret = true; return ret; }
From source file:com.OpenSource.engine.connectivity.ConnectivityInfoProvider.java
public boolean isRoaming() { NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); return (networkInfo == null) ? false : networkInfo.isRoaming(); }
From source file:com.ultrafunk.network_info.receiver.MobileDataStatusReceiver.java
private boolean isDataRoaming(Context context) { if ((dataState == TelephonyManager.DATA_CONNECTED) && telephonyManager.isNetworkRoaming()) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); return (networkInfo != null) ? networkInfo.isRoaming() : false; } else {//from w w w . j av a 2s .c om return telephonyManager.isNetworkRoaming() && MobileDataUtils.isDataRoaming(context); } }
From source file:org.ocs.android.agent.service.OCSAgentService.java
private boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { if (mOcssetting.getAutoModeNetwork() == AUTOMODE_NOROAMING && !netInfo.isRoaming()) { return true; // no roaming }//from www . j av a 2 s . co m if (mOcssetting.getAutoModeNetwork() == AUTOMODE_ANY) { return true; // any network (including roaming) } if (mOcssetting.getAutoModeNetwork() == AUTOMODE_WIFI && netInfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; // wifi only } } return false; }
From source file:androidx.work.impl.constraints.trackers.NetworkStateTracker.java
private NetworkState getActiveNetworkState() { // Use getActiveNetworkInfo() instead of getNetworkInfo(network) because it can detect VPNs. NetworkInfo info = mConnectivityManager.getActiveNetworkInfo(); boolean isConnected = info != null && info.isConnected(); boolean isValidated = isActiveNetworkValidated(); boolean isMetered = ConnectivityManagerCompat.isActiveNetworkMetered(mConnectivityManager); boolean isNotRoaming = info != null && !info.isRoaming(); return new NetworkState(isConnected, isValidated, isMetered, isNotRoaming); }
From source file:org.appcelerator.titanium.analytics.TiAnalyticsService.java
private boolean canSend() { boolean result = false; //int type = netInfo.getType(); //int subType = netInfo.getSubType(); // TODO change defaults based on implied speed of network NetworkInfo netInfo = null; try {/*from w w w. j a v a 2 s .c om*/ netInfo = connectivityManager.getActiveNetworkInfo(); } catch (SecurityException e) { Log.w(TAG, "Connectivity permissions have been removed from AndroidManifest.xml: " + e.getMessage()); } if (netInfo != null && netInfo.isConnected() && !netInfo.isRoaming()) { result = true; } return result; }
From source file:com.liato.bankdroid.appwidget.AutoRefreshService.java
private boolean shouldUpdateOnRoaming(NetworkInfo ni) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getBoolean("disable_during_roaming", false) && ni.isRoaming()) { return false; }// w w w . j a v a 2 s . c om return true; }
From source file:com.OpenSource.engine.connectivity.ConnectivityInfoProvider.java
private void notifyListeners(NetworkInfo networkInfo) { if (connectivityListenersList != null) { for (IConnectivityListener connectivityListener : connectivityListenersList) { switch (networkInfo.getState()) { case CONNECTED: connectivityListener.onConnected(networkInfo.getType()); if (networkInfo.isRoaming()) { connectivityListener.onRoaming(); }//from www .j a v a 2 s . c o m break; case CONNECTING: connectivityListener.onConnecting(networkInfo.getType()); break; case DISCONNECTED: connectivityListener.onDisconnected(networkInfo.getType()); break; case DISCONNECTING: connectivityListener.onDisconnecting(networkInfo.getType()); break; case UNKNOWN: break; } } } }
From source file:android_network.hetnet.vpn_service.Util.java
public static String getNetworkInfo(Context context) { StringBuilder sb = new StringBuilder(); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ani = cm.getActiveNetworkInfo(); List<NetworkInfo> listNI = new ArrayList<>(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) listNI.addAll(Arrays.asList(cm.getAllNetworkInfo())); else/*from www . java2 s. com*/ for (Network network : cm.getAllNetworks()) { NetworkInfo ni = cm.getNetworkInfo(network); if (ni != null) listNI.add(ni); } for (NetworkInfo ni : listNI) { sb.append(ni.getTypeName()).append('/').append(ni.getSubtypeName()).append(' ') .append(ni.getDetailedState()) .append(TextUtils.isEmpty(ni.getExtraInfo()) ? "" : " " + ni.getExtraInfo()) .append(ni.getType() == ConnectivityManager.TYPE_MOBILE ? " " + Util.getNetworkGeneration(ni.getSubtype()) : "") .append(ni.isRoaming() ? " R" : "") .append(ani != null && ni.getType() == ani.getType() && ni.getSubtype() == ani.getSubtype() ? " *" : "") .append("\r\n"); } try { Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces(); if (nis != null) while (nis.hasMoreElements()) { NetworkInterface ni = nis.nextElement(); if (ni != null && !ni.isLoopback()) { List<InterfaceAddress> ias = ni.getInterfaceAddresses(); if (ias != null) for (InterfaceAddress ia : ias) sb.append(ni.getName()).append(' ').append(ia.getAddress().getHostAddress()) .append('/').append(ia.getNetworkPrefixLength()).append(' ') .append(ni.getMTU()).append(' ').append(ni.isUp() ? '^' : 'v') .append("\r\n"); } } } catch (Throwable ex) { sb.append(ex.toString()).append("\r\n"); } if (sb.length() > 2) sb.setLength(sb.length() - 2); return sb.toString(); }
From source file:biz.shadowservices.DegreesToolbox.DataFetcher.java
public boolean isRoaming(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (info == null) { return false; } else {//ww w. j a v a2s . com return info.isRoaming(); } }