开发者

retrieve Android ARM processor version programmatically

Is there a way to retrieve the ARM processo开发者_StackOverflowr version programmatically? I'm trying to send it to Google Analytics. I've been told it's in the /proc/cpuinfo folder but I'm unsure how to retrieve this information in code.


From http://android-er.blogspot.com/2009/09/read-android-cpu-info.html:

private String ReadCPUinfo()
 {
  ProcessBuilder cmd;
  String result="";

  try{
   String[] args = {"/system/bin/cat", "/proc/cpuinfo"};
   cmd = new ProcessBuilder(args);

   Process process = cmd.start();
   InputStream in = process.getInputStream();
   byte[] re = new byte[1024];
   while(in.read(re) != -1){
    System.out.println(new String(re));
    result = result + new String(re);
   }
   in.close();
  } catch(IOException ex){
   ex.printStackTrace();
  }
  return result;
 }

You can just do split on each line in the result and look for the line that starts with Processor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜