Android NetworkInfo.State - 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.State class.

This code example shows how to use the following methods:toString
            Log.v(LOG_TAG, "no broadcast is expected, instead broadcast is probably received");
            mReason = "no broadcast is expected, instead broadcast is probably received";
            return false; 
        } else if (mStateDepository.get(0) != mTransitionTarget) {
            Log.v(LOG_TAG, String.format("%s is expected, but it is %s",
                    mTransitionTarget.toString(),
                    mStateDepository.get(0).toString()));
            mReason = String.format("%s is expected, but it is %s",
                    mTransitionTarget.toString(),
                    mStateDepository.get(0).toString());
            return false; 
        } 
        return true; 
    } 
 
    /** 
     * Verify the network state to disconnection 
     * @return false if any of the state transitions were not valid 
     */ 
    private boolean validateNetworkDisconnection() { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
    public static boolean isDeviceOnline(Context context) {
        ConnectivityManager cMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = cMgr.getActiveNetworkInfo();
        if (netInfo == null || netInfo.getState() == null)
            return false; 
        return netInfo.getState().equals(State.CONNECTED);
    } 
     
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:compareTo
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo info = manager.getActiveNetworkInfo();
        if (info == null) {
            Log.d(TAG, "no network found");
            return false; 
        } else if (info.getState().equals(State.CONNECTED)) {
            Log.d(TAG, "network state = CONNECTED");
            return true; 
        } else { 
            Log.d(TAG, "network state != CONNECTED, " + info.getState().toString());
            return false; 
        } 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
	 * @return True if there is internet connectivity, false otherwise. 
	 */ 
	public boolean internetAvailable() { 
		ConnectivityManager manager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = manager.getActiveNetworkInfo();
		if (info == null || info.getState().equals(State.DISCONNECTED))
			return false; 
		return true; 
	} 
	 
} 
 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
		NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
		if (!wifiOnly && netInfo != null && netInfo.isConnectedOrConnecting()) {
			return true; 
		} else if (wifiOnly) {
			State wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
			if (State.CONNECTED.equals(wifiInfo) || State.CONNECTING.equals(wifiInfo)) {
				return true; 
			} 
		} 
		return false; 
	} 
 
	public String getId() {
		return url;
	} 
 
	public boolean add(File file) {
		//Log.d("HTTPS3Archive","HTTPS3Archive" ); 
		return IOUtil.isValidUrl(url) ? uploadFile(file, url) : false;
	} 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
 
	private boolean connectionPresent () { 
		ConnectivityManager cMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo netInfo = cMgr.getActiveNetworkInfo();
		if ((netInfo != null) && (netInfo.getState() != null)) {
			return netInfo.getState().equals(State.CONNECTED);
		} 
		return false; 
	} 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
		if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
 
			final NetworkInfo networkInfo = intent
					.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
 
			if (networkInfo.getState().equals(State.CONNECTED)) {
				enableSync(); 
			} else if (networkInfo.getState().equals(State.DISCONNECTED)) {
				disableSync(); 
			} 
 
		} else if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
 
			final int wifiState = intent.getIntExtra(
					WifiManager.EXTRA_WIFI_STATE,
					WifiManager.WIFI_STATE_ENABLED);
 
			if (wifiState == WifiManager.WIFI_STATE_DISABLED) {
				disableSync(); 
			} else if (wifiState == WifiManager.WIFI_STATE_ENABLED) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
	} 
 
	private boolean isInternetAvailable() { 
		ConnectivityManager manager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = manager.getActiveNetworkInfo();
		if (info == null || info.getState().equals(State.DISCONNECTED))
			return false; 
		return true; 
	} 
	 
	public void showToast(String message) {
		Bundle bundle = new Bundle();
		bundle.putString("message", message);
		Message msg = handler.obtainMessage();
		msg.setData(bundle);
		handler.sendMessage(msg);
	} 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
 
	public static boolean connectionPresent (final Context context) {
		final ConnectivityManager cMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		final NetworkInfo netInfo = cMgr.getActiveNetworkInfo();
		if ((netInfo != null) && (netInfo.getState() != null)) {
			return netInfo.getState().equals(State.CONNECTED);
		} 
		return false; 
	} 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android NetworkInfo.State Questions & Answers:

See Code Examples for Android NetworkInfo.State Methods: