Android Handler警告,SimpleDateFormat警告
1:Handler
// This Handler class should be static or leaks might occur: IncomingHandler
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
};
};
解决方法:
private Handler mHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
return false;
}
});
2:SimpleDateFormat
// To get local formatting use getDateInstance(), getDateTimeInstance(), or
// getTimeInstance(), or use new SimpleDateFormat(String template, Locale
// locale) with for example Locale.US for ASCII dates.
@SuppressLint("SimpleDateFormat")
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
"yyyy-MM-ddHH:mm:ss");
解决方法:
SimpleDateFormat newSimpleDateFormat = new SimpleDateFormat(
"yyyy年MM月dd日HH时mm分", Locale.getDefault());
3:new HashMap()
@SuppressLint("UseSparseArrays")
public static Map CMD_MAP = new HashMap();
警告原因:Use new SparseArray(...) instead for better performance
4:"String".toUpperCase(); "String".toLowerCase();
@SuppressLint("DefaultLocale")
boolean b = "String".toUpperCase().equals("STRING");
解决方法:
boolean b = "String".equalsIgnoreCase("STRING");
警告原因:Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead
最新文章
- C#错过的10年
- 《数据结构》2.2顺序表(sequence list)
- Effective C++ -----条款44:将与参数无关的代码抽离templates
- android程序---->;android多线程下载(一)
- 通俗易懂------this指向
- ORCALE用户授权与创建同义词
- NFS参数配置详细说明
- Qt解析XML文件(QXmlStreamReader)
- HDU 5044 离线LCA算法
- 关于Cocos2dx之JS创建项目
- .Neter玩转Linux系列之二:Linux下的文件目录及文件目录的权限
- java跟oracle如何计算时间差
- HTML百宝箱(1从0开始)
- JS关键字和保留字汇总(小记)
- 微信小程序,加载更多
- Property referenced in indexed property path is neither an array nor a List nor a Map
- Howto Building GNU Toolchains
- PHPSQL注入
- networkManger介绍
- 怎样解决IIS6.0上传文件限制的问题?
热门文章
- 四. Java继承和多态1. 继承的概念与实现
- 图床plus演示 | 图床及在线分享演示文稿工具
- MySQL四种类型日志:Error Log、General Query Log、Binary Log、Slow Query Log
- [Bug] 未找到导入的项目“C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets”
- Stub, Mock and Proxy Testing
- 1019(C++)
- 遗传算法解决TSP问题
- Hadoop之Mapreduce详解
- .Net程序测试阿里云OSS开放存储服务
- SQL Server 2008 导入MDF数据库文件