本文整理汇总了Java中android.net.Proxy.getDefaultHost方法的典型用法代码示例。如果您正苦于以下问题:Java Proxy.getDefaultHost方法的具体用法?Java Proxy.getDefaultHost怎么用?Java Proxy.getDefaultHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.Proxy
的用法示例。
在下文中一共展示了Proxy.getDefaultHost方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: b
import android.net.Proxy; //导入方法依赖的package包/类
private static String b(Context context)
{
if (android.os.Build.VERSION.SDK_INT < 11)
{
if (context != null)
{
String s = Proxy.getHost(context);
if (TextUtils.isEmpty(s))
{
s = Proxy.getDefaultHost();
}
return s;
} else
{
return Proxy.getDefaultHost();
}
} else
{
return System.getProperty("http.proxyHost");
}
}
示例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;
}
示例4: b
import android.net.Proxy; //导入方法依赖的package包/类
private static String b(Context context) {
if (VERSION.SDK_INT >= 11) {
return System.getProperty("http.proxyHost");
}
if (context == null) {
return Proxy.getDefaultHost();
}
String host = Proxy.getHost(context);
if (TextUtils.isEmpty(host)) {
return Proxy.getDefaultHost();
}
return host;
}
示例5: 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);
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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()};
}