当前位置: 首页>>代码示例>>Java>>正文


Java Proxy.getPort方法代码示例

本文整理汇总了Java中android.net.Proxy.getPort方法的典型用法代码示例。如果您正苦于以下问题:Java Proxy.getPort方法的具体用法?Java Proxy.getPort怎么用?Java Proxy.getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.net.Proxy的用法示例。


在下文中一共展示了Proxy.getPort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: a

import android.net.Proxy; //导入方法依赖的package包/类
private static int a(Context context) {
    int i = -1;
    if (VERSION.SDK_INT >= 11) {
        Object property = System.getProperty("http.proxyPort");
        if (TextUtils.isEmpty(property)) {
            return i;
        }
        try {
            return Integer.parseInt(property);
        } catch (NumberFormatException e) {
            return i;
        }
    } else if (context == null) {
        return Proxy.getDefaultPort();
    } else {
        i = Proxy.getPort(context);
        if (i < 0) {
            return Proxy.getDefaultPort();
        }
        return i;
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:HttpUtils.java

示例2: getProxy

import android.net.Proxy; //导入方法依赖的package包/类
/**
 * @param context context
 * @param info current network info
 * @return the proxy to be used for the given network, or null
 */
public static String getProxy(Context context, NetworkInfo info) {
    final String proxy;
    if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
        // adjust mobile proxy settings
        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) {
            proxy = new HttpHost(proxyHost, proxyPort).toURI();
        } else {
            proxy = null;
        }
    } else {
        proxy = null;
    }
    return proxy;
}
 
开发者ID:tsenart,项目名称:listen-later,代码行数:28,代码来源:IOUtils.java

示例3: getPreferredHttpHost

import android.net.Proxy; //导入方法依赖的package包/类
/**
 * Returns the preferred proxy to be used by clients. This is a wrapper
 * around {@link android.net.Proxy#getHost()}. Currently no proxy will be
 * returned for localhost or if the active network is Wi-Fi.
 * 
 * @param context the context which will be passed to
 *            {@link android.net.Proxy#getHost()}
 * @param url the target URL for the request
 * @note Calling this method requires permission
 *       android.permission.ACCESS_NETWORK_STATE
 * @return The preferred proxy to be used by clients, or null if there is no
 *         proxy.
 */
public HttpHost getPreferredHttpHost(Context context,
        String url) {
    if (!isLocalHost(url) && !mService.isWiFi()) {
        final String proxyHost = Proxy.getHost(context);
        if (proxyHost != null) {
            return new HttpHost(proxyHost, Proxy.getPort(context), "http");
        }
    }

    return null;
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:25,代码来源:DownloadThread.java

示例4: getPreferredHttpHost

import android.net.Proxy; //导入方法依赖的package包/类
/**
    * Returns the preferred proxy to be used by clients. This is a wrapper
    * around {@link android.net.Proxy#getHost()}. Currently no proxy will be
    * returned for localhost or if the active network is Wi-Fi.
    * 
    * @param context the context which will be passed to
    *            {@link android.net.Proxy#getHost()}
    * @param url the target URL for the request
    * @note Calling this method requires permission
    *       android.permission.ACCESS_NETWORK_STATE
    * @return The preferred proxy to be used by clients, or null if there is no
    *         proxy.
    */
   @SuppressWarnings("deprecation")
public HttpHost getPreferredHttpHost(Context context,
           String url) {
       if (!isLocalHost(url) && !mService.isWiFi()) {
           final String proxyHost = Proxy.getHost(context);
           if (proxyHost != null) {
               return new HttpHost(proxyHost, Proxy.getPort(context), "http");
           }
       }

       return null;
   }
 
开发者ID:CmdrStardust,项目名称:Alite,代码行数:26,代码来源:DownloadThread.java

示例5: getPreferredHttpHost

import android.net.Proxy; //导入方法依赖的package包/类
/**
 * Returns the preferred proxy to be used by clients. This is a wrapper
 * around {@link Proxy#getHost()}. Currently no proxy will be
 * returned for localhost or if the active network is Wi-Fi.
 *
 * @param context the context which will be passed to
 *                {@link Proxy#getHost()}
 * @param url     the target URL for the request
 * @return The preferred proxy to be used by clients, or null if there is no
 * proxy.
 * @note Calling this method requires permission
 * android.permission.ACCESS_NETWORK_STATE
 */
public HttpHost getPreferredHttpHost(Context context,
                                     String url) {
    if (!isLocalHost(url) && !mService.isWiFi()) {
        final String proxyHost = Proxy.getHost(context);
        if (proxyHost != null) {
            return new HttpHost(proxyHost, Proxy.getPort(context), "http");
        }
    }

    return null;
}
 
开发者ID:islamsamak,项目名称:janadroid,代码行数:25,代码来源:DownloadThread.java


注:本文中的android.net.Proxy.getPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。