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


Java Proxy.getDefaultPort方法代码示例

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


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

示例1: a

import android.net.Proxy; //导入方法依赖的package包/类
private static HttpURLConnection a(URL url, String str) throws IOException {
    String replaceFirst;
    int i = 80;
    String defaultHost = Proxy.getDefaultHost();
    int defaultPort = Proxy.getDefaultPort();
    if (defaultPort == -1) {
        defaultPort = 80;
    }
    String host = url.getHost();
    int port = url.getPort();
    if (port != -1) {
        i = port;
    }
    if (str.indexOf(new StringBuilder(String.valueOf(host)).append(NetworkUtils.DELIMITER_COLON).append(i).toString()) != -1) {
        replaceFirst = str.replaceFirst(new StringBuilder(String.valueOf(host)).append(NetworkUtils.DELIMITER_COLON).append(i).toString(), new StringBuilder(String.valueOf(defaultHost)).append(NetworkUtils.DELIMITER_COLON).append(defaultPort).toString());
    } else {
        replaceFirst = str.replaceFirst(host, new StringBuilder(String.valueOf(defaultHost)).append(NetworkUtils.DELIMITER_COLON).append(defaultPort).toString());
    }
    try {
        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(replaceFirst).openConnection();
        httpURLConnection.setRequestProperty("X-Online-Host", new StringBuilder(String.valueOf(host)).append(NetworkUtils.DELIMITER_COLON).append(i).toString());
        return httpURLConnection;
    } catch (MalformedURLException e) {
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:27,代码来源:q.java

示例2: 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

示例3: 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

示例4: v

import android.net.Proxy; //导入方法依赖的package包/类
public static HttpHost v(Context context) {
    if (context == null) {
        return null;
    }
    try {
        if (context.getPackageManager().checkPermission("android.permission" +
                ".ACCESS_NETWORK_STATE", context.getPackageName()) != 0) {
            return null;
        }
        NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService
                ("connectivity")).getActiveNetworkInfo();
        if (activeNetworkInfo == null) {
            return null;
        }
        if (activeNetworkInfo.getTypeName() != null && activeNetworkInfo.getTypeName()
                .equalsIgnoreCase("WIFI")) {
            return null;
        }
        String extraInfo = activeNetworkInfo.getExtraInfo();
        if (extraInfo == null) {
            return null;
        }
        if (extraInfo.equals("cmwap") || extraInfo.equals("3gwap") || extraInfo.equals
                ("uniwap")) {
            return new HttpHost(Network.CMWAP_GATEWAY, 80);
        }
        if (extraInfo.equals("ctwap")) {
            return new HttpHost("10.0.0.200", 80);
        }
        String defaultHost = Proxy.getDefaultHost();
        if (defaultHost != null && defaultHost.trim().length() > 0) {
            return new HttpHost(defaultHost, Proxy.getDefaultPort());
        }
        return null;
    } catch (Throwable th) {
        cT.b(th);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:39,代码来源:l.java

示例5: c

import android.net.Proxy; //导入方法依赖的package包/类
private HttpHost c() {
    String g;
    if (VERSION.SDK_INT >= 11) {
        g = g();
        if (g != null && !g.contains("wap")) {
            return null;
        }
        URL b = b();
        if (b == null) {
            return null;
        }
        b.a.equalsIgnoreCase(b.getProtocol());
        Object property = System.getProperty("https.proxyHost");
        String property2 = System.getProperty("https.proxyPort");
        if (TextUtils.isEmpty(property)) {
            return null;
        }
        return new HttpHost(property, Integer.parseInt(property2));
    }
    NetworkInfo f = f();
    if (f == null || !f.isAvailable() || f.getType() != 0) {
        return null;
    }
    g = Proxy.getDefaultHost();
    int defaultPort = Proxy.getDefaultPort();
    if (g != null) {
        return new HttpHost(g, defaultPort);
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:31,代码来源:a.java

示例6: d

import android.net.Proxy; //导入方法依赖的package包/类
private HttpHost d() {
    NetworkInfo f = f();
    if (f == null || !f.isAvailable() || f.getType() != 0) {
        return null;
    }
    String defaultHost = Proxy.getDefaultHost();
    int defaultPort = Proxy.getDefaultPort();
    if (defaultHost != null) {
        return new HttpHost(defaultHost, defaultPort);
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:a.java

示例7: a

import android.net.Proxy; //导入方法依赖的package包/类
private static HttpURLConnection a(URL url, String s)
{
    int k = 80;
    String s1 = Proxy.getDefaultHost();
    int l = Proxy.getDefaultPort();
    if (l == -1)
    {
        l = k;
    }
    String s2 = url.getHost();
    int i1 = url.getPort();
    String s3;
    URL url1;
    HttpURLConnection httpurlconnection;
    if (i1 != -1)
    {
        k = i1;
    }
    if (s.indexOf((new StringBuilder(String.valueOf(s2))).append(":").append(k).toString()) != -1)
    {
        s3 = s.replaceFirst((new StringBuilder(String.valueOf(s2))).append(":").append(k).toString(), (new StringBuilder(String.valueOf(s1))).append(":").append(l).toString());
    } else
    {
        s3 = s.replaceFirst(s2, (new StringBuilder(String.valueOf(s1))).append(":").append(l).toString());
    }
    try
    {
        url1 = new URL(s3);
    }
    catch (MalformedURLException malformedurlexception)
    {
        return null;
    }
    httpurlconnection = (HttpURLConnection)url1.openConnection();
    httpurlconnection.setRequestProperty("X-Online-Host", (new StringBuilder(String.valueOf(s2))).append(":").append(k).toString());
    return httpurlconnection;
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:38,代码来源:i.java

示例8: getProxyHostAndPort

import android.net.Proxy; //导入方法依赖的package包/类
public static String[] getProxyHostAndPort(Context context) {
    return getNetworkType(context) == NetworkType.WIFI ?
            new String[]{"", "-1"}
            : new String[]{Proxy.getDefaultHost(), "" + Proxy.getDefaultPort()};
}
 
开发者ID:pinguo-sunjianfei,项目名称:Android-Application-ZJB,代码行数:6,代码来源:NetworkUtil.java


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