Activity 利用 Build.VERSION 來取得手機 OS Version 版本


在 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 );
}
}

範例結果 :


天聖經:神的心不僅在神的聖言當中,也在神所創造的萬物之中,天涯海角每一處都有神的心
Related Posts Plugin for WordPress, Blogger...