一:跑项目的时候会AS会报个提示,如下图
原因:1:手机内存不足。2:开发者选项 usb调试未打开
二:用if语句的时候最好接个else语句,否则可能出现复用现象
三:app启动白屏 or 黑屏
解决办法:1.@null换个背景
2:true 变成透明
Activity反复跳转出现黑屏也可用上面的第二种方法解决。
四:防止重复点击事件
private long lastClickTime;
public boolean isFastDoubleClick() {
long time = System.currentTimeMillis();
long timeD = time - lastClickTime;
if (0 < timeD && timeD < 1000) {
return true;}
lastClickTime = time;
return false;
}
五:判断第一次启动app
private void isFirstLoad() {
boolean isFirstLoad = preferences.getBoolean(“isFirstLoad”, true);
if (isFirstLoad){
edit.putBoolean(“isFirstLoad”,false);
edit.commit();//第一次进入设置初始数据,之后就只执行查询
} else { }
}
六:GreenDao的使用
https://blog.youkuaiyun.com/qq_38520096/article/details/78833801
七:Retrofit 2.0 使用教程
https://blog.youkuaiyun.com/carson_ho/article/details/73732076
八:时间戳和时间转换的工具类
public class DateUtils {
/**
* 时间戳转为时间(年月日,时分秒)
*
* @param cc_time 时间戳
* @return
*/
public static String getStrTime(String cc_time) {
String re_StrTime = null;
//同理也可以转为其它样式的时间格式.例如:”yyyy/MM/dd HH:mm”
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy/MM/dd HH:mm:ss”);
// 例如:cc_time=1291778220
long lcc_time = Long.valueOf(cc_time);
re_StrTime = sdf.format(new Date(lcc_time * 1000L));
return re_StrTime;
}
/**
* 时间转换为时间戳
*
* @param timeStr 时间 例如: 2016-03-09
* @param format 时间对应格式 例如: yyyy-MM-dd
* @return
*/
public static long getTimeStamp(String timeStr, String format) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
Date date = null;
try {
date = simpleDateFormat.parse(timeStr);
long timeStamp = date.getTime();
return timeStamp;
} catch (ParseException e) {
e.printStackTrace();
}
return 0;
}
}
九:数字转为人民币方法
//数字转换为人民币形式 带¥符号
public static String getNumberFormat(long i){
return NumberFormat.getCurrencyInstance().format(i);
}
//数字转换为人民币形式不带符号
public static String getDcimalFormat(long i){
DecimalFormat decimalFormat = new DecimalFormat(“##,###,###,###,##0.00”);
return decimalFormat.format(i);
}、
十:时段划分
//时段划分
public static String time(int hour){
String mTvTime = null;
if (hour == 1 || hour ==2 || hour ==3 || hour == 4 || hour == 5){
mTvTime=(“凌晨好”); }
if (hour == 6 || hour ==7 || hour ==8 || hour == 9 || hour == 10 ||hour == 11){
mTvTime=(“早上好”);
}
if (hour == 14 || hour ==15 || hour ==16 || hour == 17|| hour == 18 ){
mTvTime=("下午好");
}
if (hour == 19 || hour ==20 || hour ==21 || hour == 22 ){
mTvTime=("晚上好");
}
if (hour == 12 || hour ==13 ){
mTvTime=("中午好");
}
if (hour == 0 || hour ==23 ){
mTvTime=("深夜好");
}
return mTvTime;
}
十一:网易云音乐的api前缀链接http://musicapi.leanapp.cn/