在 Android 中,
若要取得 Android OS 版本,
可以利用 VERSION 物件,
參考範例, 如下 :
Java 程式範例 :
程式碼
public class helloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 顯示 OS Version 相關資訊
TextView tv = new TextView(this);
tv.setText( "CODENAME: " + VERSION.CODENAME + "\n"
+ "INCREMENTAL: " + VERSION.INCREMENTAL + "\n"
+ "RELEASE: " + VERSION.RELEASE + "\n"
+ "SDK: " + VERSION.SDK + "\n"
+ "SDK_INT: " + VERSION.SDK_INT
);
setContentView( tv );
}
}
範例結果 :