List of usage examples for android.net Proxy getDefaultPort
@Deprecated public static final int getDefaultPort()
From source file:net.primeranks.fs_viewer.fs_replay.ConnectionChangedBroadcastReceiver.java
public void onReceive(Context context, Intent intent) { String info = intent.getStringExtra(ConnectivityManager.EXTRA_EXTRA_INFO); NetworkInfo nwInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); Log.d(Config.LOG_AS, info + ": " + nwInfo.getReason()); HttpParams httpParams = EntryPointActivity.getHttpClient().getParams(); if (nwInfo.getType() == ConnectivityManager.TYPE_MOBILE) { String proxyHost = Proxy.getHost(context); if (proxyHost == null) { proxyHost = Proxy.getDefaultHost(); }/* w ww.ja va2s .com*/ int proxyPort = Proxy.getPort(context); if (proxyPort == -1) { proxyPort = Proxy.getDefaultPort(); } if (proxyHost != null && proxyPort > -1) { HttpHost proxy = new HttpHost(proxyHost, proxyPort); httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } else { httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } } else { httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } }
From source file:com.github.ignition.support.http.IgnitedHttpClient.java
public void updateProxySettings() { if (appContext == null) { return;// ww w.j a v a2s . c o m } HttpParams httpParams = httpClient.getParams(); ConnectivityManager connectivity = (ConnectivityManager) appContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo nwInfo = connectivity.getActiveNetworkInfo(); if (nwInfo == null) { return; } Log.i(LOG_TAG, nwInfo.toString()); if (nwInfo.getType() == ConnectivityManager.TYPE_MOBILE) { String proxyHost = Proxy.getHost(appContext); if (proxyHost == null) { proxyHost = Proxy.getDefaultHost(); } int proxyPort = Proxy.getPort(appContext); if (proxyPort == -1) { proxyPort = Proxy.getDefaultPort(); } if (proxyHost != null && proxyPort > -1) { HttpHost proxy = new HttpHost(proxyHost, proxyPort); httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } else { httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } } else { httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } }
From source file:com.wiyun.engine.network.Network.java
static HttpHost getProxy() { return new HttpHost(Proxy.getDefaultHost(), Proxy.getDefaultPort()); }
From source file:com.DGSD.DGUtils.Http.BetterHttp.java
public static void updateProxySettings() { if (appContext == null) { return;/*from ww w. ja v a 2s . com*/ } HttpParams httpParams = httpClient.getParams(); ConnectivityManager connectivity = (ConnectivityManager) appContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo nwInfo = connectivity.getActiveNetworkInfo(); if (nwInfo == null) { return; } Log.i(LOG_TAG, nwInfo.toString()); if (nwInfo.getType() == ConnectivityManager.TYPE_MOBILE) { String proxyHost = Proxy.getHost(appContext); if (proxyHost == null) { proxyHost = Proxy.getDefaultHost(); } int proxyPort = Proxy.getPort(appContext); if (proxyPort == -1) { proxyPort = Proxy.getDefaultPort(); } if (proxyHost != null && proxyPort > -1) { HttpHost proxy = new HttpHost(proxyHost, proxyPort); httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } else { httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } } else { httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } }
From source file:cn.edu.szjm.support.http.IgnitedHttp.java
/** * Updates the underlying HTTP client's proxy settings with what the user has entered in the APN * settings. This will be called automatically if {@link #listenForConnectivityChanges(Context)} * has been called. <b>This requires the {@link Manifest.permission#ACCESS_NETWORK_STATE} * permission</b>.//www .ja v a 2 s. c om * * @param context * the current context */ public void updateProxySettings(Context context) { if (context == null) { return; } HttpParams httpParams = httpClient.getParams(); ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo nwInfo = connectivity.getActiveNetworkInfo(); if (nwInfo == null) { return; } Log.i(LOG_TAG, nwInfo.toString()); if (nwInfo.getType() == ConnectivityManager.TYPE_MOBILE) { String proxyHost = Proxy.getHost(context); if (proxyHost == null) { proxyHost = Proxy.getDefaultHost(); } int proxyPort = Proxy.getPort(context); if (proxyPort == -1) { proxyPort = Proxy.getDefaultPort(); } if (proxyHost != null && proxyPort > -1) { HttpHost proxy = new HttpHost(proxyHost, proxyPort); httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } else { httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } } else { httpParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, null); } }