標籤:lock 擷取 檔案 service double ext his 形式 self
寫入本地檔案
private void getMemo(){ //獲得ActivityManager服務的對象 ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); //獲得MemoryInfo對象 ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo() ; //獲得系統可用記憶體,儲存在MemoryInfo對象上 mActivityManager.getMemoryInfo(memoryInfo) ; long memSize = memoryInfo.availMem ; selfHttpRequest.writeToLoacl(memSize+""); Toast.makeText(this, "success", Toast.LENGTH_SHORT).show(); }
Toast形式
private void toastMemo(){ //獲得ActivityManager服務的對象 ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); //獲得MemoryInfo對象 ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo() ; //獲得系統可用記憶體,儲存在MemoryInfo對象上 mActivityManager.getMemoryInfo(memoryInfo) ; long memSize = memoryInfo.availMem ; double mem = memSize / (1000*1000); Toast.makeText(this, mem+"MB ", Toast.LENGTH_SHORT).show(); }
Android擷取當前可用記憶體