注册账号-全站资源免费下载
您需要 登录 才可以下载或查看,没有账号?注册账号
x
[color=rgba(51, 51, 51, 0.88)]获取设备内存
[JavaScript] 纯文本查看 复制代码 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();
|