中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

android系統(tǒng)進(jìn)程手機(jī)內(nèi)存工具類

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
    public class TaskUtils {  
      
        /** 
         * 獲取正在運(yùn)行的進(jìn)程的個(gè)數(shù) 
         *  
         * @param context 
         * @return 
         */  
        public static int getRunningProcessCount(Context context) {  
            // 得到系統(tǒng)的任務(wù)管理器.  
            ActivityManager am = (ActivityManager) context  
                    .getSystemService(Context.ACTIVITY_SERVICE);  
            return am.getRunningAppProcesses().size();  
        }  
      
        /** 
         * 獲取手機(jī)的可用內(nèi)存 
         *  
         * @param context 
         * @return long類型數(shù)據(jù) 總的可用內(nèi)存 
         */  
        public static long getAvailRam(Context context) {  
            ActivityManager am = (ActivityManager) context  
                    .getSystemService(Context.ACTIVITY_SERVICE);  
            ActivityManager.MemoryInfo outInfo = new MemoryInfo();  
            am.getMemoryInfo(outInfo);  
            return outInfo.availMem;  
        }  
      
        /** 
         * 獲取手機(jī)的總內(nèi)存 
         *  
         * @return 
         */  
        public static long getTotalRam() {  
            try {  
                File file = new File("/proc/meminfo");  
                FileInputStream fis = new FileInputStream(file);  
                BufferedReader br = new BufferedReader(new InputStreamReader(fis));  
                // MemTotal: 253604 kB  
                String result = br.readLine();  
                StringBuffer sb = new StringBuffer();  
                char[] chars = result.toCharArray();  
                for (char c : chars) {  
                    if (c >= '0' && c <= '9') {  
                        sb.append(c);  
                    }  
                }  
                return Long.parseLong(sb.toString()) * 1024;  
            } catch (Exception e) {  
                // TODO Auto-generated catch block  
                e.printStackTrace();  
                return 0;  
      
            }  
        }  
    }  

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:Android屏蔽Home鍵代碼

下一篇: JQuery其他常用函數(shù)