fanfou(饭否) android客户端 代码学习3
16lz
2021-01-24
参考博文:
关于HttpClient的总结(一) java中Logger.getLogger
HttpClient.class
/** * Bad Request: The request was invalid. An accompanying error message will * explain why. This is the status code will be returned during rate * limiting. * (Rate Limiting):对数据包进行修整。防止不正常数据包攻击目标, * 对每个数据流业务进行修整,处罚长时间消耗大量资源的源头。 */ public static final int BAD_REQUEST = 400;
/** * Service Unavailable: The Weibo servers are up, but overloaded with * requests. Try again later. The search and trend methods use this to * indicate when you are being rate limited. */ public static final int SERVICE_UNAVAILABLE = 503;
包含的参数
/**The class represents an authentication scope consisting of a host name, a port number, a realm name and an authentication scheme name which Credentials apply to.*/private AuthScope mAuthScope
private DefaultHttpClient mClient;
private BasicHttpContext localcontext;
private String mUserId;
private String mPassword;
private OAuthClient mOAuthClient;
private String mOAuthBaseUrl = Configuration.getOAuthBaseUrl();
简述Configuration.class
public class Configuration { private static Properties defaultProperty; static { init(); } /* package */static void init() { defaultProperty.setProperty("fanfoudroid.oauth.baseUrl","http://fanfou.com/oauth");....通过public static String getOAuthBaseUrl() { return getProperty("fanfoudroid.oauth.baseUrl"); } public static String getProperty(String name) { return getProperty(name, null); }//fallbackValue当没有这个property时被返回值 public static String getProperty(String name, String fallbackValue) { String value; try { value = System.getProperty(name, fallbackValue); if (null == value) {//从自定义默认的Property取值 value = defaultProperty.getProperty(name); //从系统取值..... value = System.getProperty(fallback);..... } catch (AccessControlException ace) { // Unsigned applet cannot access System properties value = fallbackValue; }//去掉value里面包含{ }..用到substring,indexof..不做介绍 return replace(value); }
HttpClient.class 的无参构造类
//设置日志输出// Create and initialize HTTP parameters// Create and initialize scheme registry// Create an HttpClient with the ThreadSafeClientConnManager.// Support GZIPpublic HttpClient() { prepareHttpClient();/** * Sets the consumer key and consumer secret.<br> */ setOAuthConsumer(null, null, null);}
//设置日志输出private void enableDebug() { Log.d(TAG, "enable apache.http debug"); java.util.logging.Logger.getLogger("org.apache.http").setLevel( java.util.logging.Level.FINEST); java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel( java.util.logging.Level.FINER); java.util.logging.Logger.getLogger("org.apache.http.headers").setLevel( java.util.logging.Level.OFF);
更多相关文章
- Android(安卓)Log 日志系统
- Android学习能力之统计日志上传设计
- Logger android日志工具
- cocos2dx android 真机调试时Logcat不显示日志信息
- Android(安卓)解读main log和event log日志信息
- Kotlin log 工具类
- Android(安卓)Studio 上如何使用LogCat
- android p状态栏,插入sim卡,关闭数据流量,状态栏卡图标右下角有X图标
- android上不错的开源库