Android NetworkInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android NetworkInfo class.

This code example shows how to use the following methods: isConnectedOrConnecting
public class NetworkUtils { 
	 
	public static boolean isOnline(Context context) {
		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo netInfo = cm.getActiveNetworkInfo();
		if (netInfo != null && netInfo.isConnectedOrConnecting()) {
			return true; 
		} 
		return false; 
	} 
 
} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isConnected
 
		ConnectivityManager connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
		 
		boolean connected = (activeNetInfo != null) && (activeNetInfo.isConnected());
		 
		Logger.I(TAG, "LOGGER: Network status change, connected = " + String.valueOf(connected) );
		RhodesService.getInstance().notifyNetworkStatusChanged(connected?NETWORK_CONNECTED:NETWORK_DISCONNECTED);
	} 
} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isAvailable
  } 
 
  protected boolean isConnectivityPossible() { 
    NetworkInfo networkInfo = connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS);
    Log.w("MmsService", "Got network info: " + networkInfo);
    return networkInfo != null  && networkInfo.isAvailable();
  } 
 
  protected void finishConnectivity() { 
    Log.w("MmsService", "Calling stop using network feature!");
    connectivityManager.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, FEATURE_ENABLE_MMS);
 
    if (connectivityListener != null) {
      context.unregisterReceiver(connectivityListener);
      connectivityListener = null;
    } 
 
    if (this.wakeLock.isHeld())
      this.wakeLock.release();
  } 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isConnected
    { 
        boolean state = false;
        final ConnectivityManager conMgr =  (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
 
		final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
		if (activeNetwork != null && activeNetwork.isConnected()) {
			state = true;
		} else { 
			state = false;
		} 
 
        return state;
    } 
 
    /** 
    * To recieve network state changes 
    */ 
    public static void registerNetworkCheck() 
    { 
        IntentFilter i = new IntentFilter();
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getType
		return networkInfo != null && networkInfo.isConnected();
	} 
 
	public boolean onWiFi() { 
		NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
		return connected() && networkInfo.getType() == TYPE_WIFI;
	} 
 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android NetworkInfo Questions & Answers:

Other Android NetworkInfo Examples

16:			  if (connectivity != null) 
17:			  {
18:				  NetworkInfo[] info = connectivity.getAllNetworkInfo();
19:				  if (info != null) 
20:					  for (int i = 0; i < info.length; i++)

Read More

19:	          if (connectivity != null)
20:	          {
21:	              NetworkInfo[] info = connectivity.getAllNetworkInfo();
22:	              if (info != null)
23:	                  for (int i = 0; i < info.length; i++)

Read More

19:	          if (connectivity != null)
20:	          {
21:	              NetworkInfo[] info = connectivity.getAllNetworkInfo();
22:	              if (info != null)
23:	                  for (int i = 0; i < info.length; i++)

Read More

See Code Examples for Android NetworkInfo Methods: