端末のスペックなどの情報が載っているBuild.propを参照する方法です。
Buildクラスを使うことで、情報を参照することが出来ます。
具体的なコードは以下
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.text.format.Time;
import android.widget.TextView;
public class TerminalSpecGetActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = new TextView(this);
// 現SDKを取得
final int sdkInt = Integer.parseInt(Build.VERSION.SDK);
StringBuffer sb = new StringBuffer();
sb.append("[Build]" + "\n");
sb.append("BOARD : " + Build.BOARD + "\n");
if (sdkInt >= 8) sb.append("BOOTLOADER : " + Build.BOOTLOADER + "\n");
sb.append("BRAND : " + Build.BRAND + "\n");
if (sdkInt >= 4) sb.append("CPU_ABI : " + Build.CPU_ABI + "\n");
if (sdkInt >= 8) sb.append("CPU_ABI2 : " + Build.CPU_ABI2 + "\n");
sb.append("DEVICE : " + Build.DEVICE + "\n");
if (sdkInt >= 3) sb.append("DISPLAY : " + Build.DISPLAY + "\n");
// sb.append("FINGERPRINT : " + Build.FINGERPRINT + "\n");
if (sdkInt >= 8) sb.append("HARDWARE : " + Build.HARDWARE + "\n");
sb.append("HOST : " + Build.HOST + "\n");
sb.append("ID : " + Build.ID + "\n");
if (sdkInt >= 4) sb.append("MANUFACTURER : " + Build.MANUFACTURER + "\n");
sb.append("MODEL : " + Build.MODEL + "\n");
sb.append("PRODUCT : " + Build.PRODUCT + "\n");
if (sdkInt >= 8) sb.append("RADIO : " + Build.RADIO + "\n");
sb.append("TAGS : " + Build.TAGS + "\n");
sb.append("TYPE : " + Build.TYPE + "\n");
{
// JDBC時間エスケープ形式で出力
final Time time = new Time();
time.set(Build.TIME);
sb.append("TIME : " + time.toString() + "\n");
}
sb.append("USER : " + Build.USER + "\n");
sb.append("\n");
sb.append("[Build.VERSION]" + "\n");
// CODENAMEがREL以外?
if (!Build.VERSION.CODENAME.equals("REL")) {
if (sdkInt >= 4) {
sb.append("CODENAME : " + Build.VERSION.CODENAME + "\n");
}
}
sb.append("INCREMENTAL : " + Build.VERSION.INCREMENTAL + "\n");
sb.append("RELEASE : " + Build.VERSION.RELEASE + "\n");
sb.append("SDK : " + Build.VERSION.SDK + "\n");
tv.setText(sb);
setContentView(tv);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//End of Files
/////////////////////////////////////////////////////////////////////////////////////////////////