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