Android examples for Hardware:CPU Information
get Hardware Name
/******************************************************************************* * Copyright (c) 2011 MadRobot.// w w w . ja va 2 s .co m * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * Elton Kent - initial API and implementation ******************************************************************************/ //package com.java2s; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static String getHardwareName() { String hardwarenamestr = "{}"; try { final StringBuffer s = new StringBuffer(); final Process p = Runtime.getRuntime() .exec("cat /proc/cpuinfo"); final BufferedReader input = new BufferedReader( new InputStreamReader(p.getInputStream())); String line = ""; while ((line = input.readLine()) != null && s.toString().length() == 0) { if (line.startsWith("Hardware")) { s.append(line + "\n"); } } hardwarenamestr = s.substring(s.indexOf(":") + 2, s.length()); } catch (final Exception err) { // if ANYTHING goes wrong, just report 0 since this is only used for // performance appraisal. } return hardwarenamestr; } }