編輯:關於Android編程
/** * 開啟線程檢測軟件可用內存情況,軟件退出後, 調用System.exit(0)該線程才會停止 * * * @param sleep * 每隔一段時間檢測內存 * @param standard * 內存超過多少比例報警 */ public static void memoryWatch(final int sleep, final int standard) { if (sleep <= 0) { Log.e(TAG, "memoryWatch, invalid sleep = 0!"); return; } if (standard <= 0 && standard > 100) { Log.e(TAG, "memoryWatch, invalid standard percent = " + standard); return; } new Thread(new Runnable() { @Override public void run() { Log.d(TAG, "memoryWatch, start thread!"); while (true) { long divisor = 1024 * 1024; long maxMem = Runtime.getRuntime().maxMemory(); long totalMem = Runtime.getRuntime().totalMemory(); long freeMem = Runtime.getRuntime().freeMemory(); int percent = (int) (totalMem * 100 / maxMem); Log.d(TAG, "memoryWatch" + ", app maxMem = " + maxMem / divisor + "M, totalMem = " + totalMem / divisor + "M, freeMem = " + freeMem / divisor + "M, percent = " + percent); if (standard <= percent) { if (freeMem / divisor <= 2) { Log.e(TAG, "memoryWatch" + ", app maxMem = " + maxMem / divisor + "M, totalMem = " + totalMem / divisor + "M, freeMem = " + freeMem / divisor + "M, percent = " + percent); } else if (freeMem / divisor >= totalMem / (divisor * 2)) { Log.e(TAG, "memoryWatch" + ", app maxMem = " + maxMem / divisor + "M, totalMem = " + totalMem / divisor + "M, freeMem = " + freeMem / divisor + "M, percent = " + percent + "%" + ", reset memory warn flag = true!"); } } try { Thread.sleep(sleep); } catch (InterruptedException e) { Log.e(TAG, "memoryWatch, thread sleep exception : " + e); } } } }).start(); }
簡介由於項目需要+有網友咨詢,所以做了個橫向滑頁+某一橫向滑頁中有豎向滑頁的demo,實現有點繞彎子,但基本功能還是比較完善,發上來共享一下。效果思路第一步的思路是自己判
本文實例講述了Android編程之SMS讀取短信並保存到SQLite的方法。分享給大家供大家參考,具體如下:Android 之 SMS 短信在Android系統中是保存在
Android Lint Android Lint是在ADT 16(和 Tools 16)引入的一個新工具,可以掃描Android 項目源碼中潛在的bug
紅米手機官方微博正式公布了7月27日新品發布會主角之一——紅米Pro。除此之外,還有一款神秘新品露面,不出意外的話,應該就是小米筆記