Android 设置定时刷新页面数据,最小自动刷新时间
生活随笔
收集整理的這篇文章主要介紹了
Android 设置定时刷新页面数据,最小自动刷新时间
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
設置初始時間
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//設置日期格式 String thistime = df.format(new Date());SharedPreferences sharedPreferences = getSharedPreferences("industryInfo", Context.MODE_PRIVATE); //私有數據SharedPreferences.Editor editor = sharedPreferences.edit();//獲取編輯器editor.putString(“retime”, thistime);//名稱 ideditor.commit();//提交?
檢測是否刷新頁面數據
SharedPreferences share = getSharedPreferences("industryInfo", Activity.MODE_PRIVATE); String industryOne = share.getString("retime", "");//名稱 獲取id Log.i("Lgq","sss==="+industryOne);SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//設置日期格式 String nowtime = df.format(new Date());int distime= getDistanceTimemin(industryOne,nowtime); if (distime>=5){SharedPreferences sharedPreferences = getSharedPreferences("industryInfo", Context.MODE_PRIVATE); //私有數據SharedPreferences.Editor editor = sharedPreferences.edit();//獲取編輯器editor.putString("retime", nowtime);//名稱 ideditor.commit();//提交//todo刷新 } Log.i("lgq","sssss====="+distime+"...."+nowtime);?
計算時間差方法getDistanceTimemin:https://blog.csdn.net/meixi_android/article/details/81868895
?
?
總結
以上是生活随笔為你收集整理的Android 设置定时刷新页面数据,最小自动刷新时间的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【数理统计】数理统计的简单认识
- 下一篇: 实践 | 图片文本爬虫与数据分析