获取设备内存
function getMemInfo(){ plus.android.importClass('java.io.BufferedReader') var localFileReader = plus.android.newObject('java.io.FileReader','/proc/meminfo') var localBufferedReader = plus.android.newObject('java.io.BufferedReader',localFileReader,8192) var str = localBufferedReader.readLine().toString(); var totalMemStr = str; var avaMemStr = '' var i = 0 while(i<2){ str = localBufferedReader.readLine().toString(); avaMemStr = str; i++ } totalMemStr = (parseInt(totalMemStr.toUpperCase().replace(/(( )|(:)|[A-Z])/gi,''))/1024).toFixed(0) avaMemStr = (parseInt(avaMemStr.toUpperCase().replace(/(( )|(:)|[A-Z])/gi,''))/1024).toFixed(0) console.log(totalMemStr); console.log(avaMemStr); return {total:totalMemStr,ava:avaMemStr} } getMemInfo();
发表评论