Monday, July 16, 2012

Get Android OS info from android.os.Build in Android


package com.GetOsBuildInfo;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
 
public class GetOsBuildInfo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
         
        TextView device = (TextView)findViewById(R.id.device);
        TextView model = (TextView)findViewById(R.id.model);
        TextView product = (TextView)findViewById(R.id.product);
        TextView codename = (TextView)findViewById(R.id.codename);
        TextView incremental = (TextView)findViewById(R.id.incremental);
        TextView release = (TextView)findViewById(R.id.release);
        TextView sdk = (TextView)findViewById(R.id.sdk);
        TextView sdkInt = (TextView)findViewById(R.id.sdk_int);
         
        device.setText("android.os.Build.DEVICE: " + android.os.Build.DEVICE);
        model.setText("android.os.Build.MODEL: " + android.os.Build.MODEL);
        product.setText("android.os.Build.PRODUCT: " + android.os.Build.PRODUCT);
        codename.setText("android.os.Build.VERSION.CODENAME: " + android.os.Build.VERSION.CODENAME);
        incremental.setText("android.os.Build.VERSION.INCREMENTAL: " + android.os.Build.VERSION.INCREMENTAL);
        release.setText("android.os.Build.VERSION.RELEASE: " + android.os.Build.VERSION.RELEASE);
        sdk.setText("android.os.Build.VERSION.SDK: " + android.os.Build.VERSION.SDK);
        sdkInt.setText("android.os.Build.VERSION.SDK_INT: " + String.valueOf(android.os.Build.VERSION.SDK_INT));
    }
}



<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     > <TextView      android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/hello"     /> <TextView     android:id="@+id/device"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     /> <TextView     android:id="@+id/model"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     /> <TextView     android:id="@+id/product"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     /> <TextView     android:id="@+id/codename"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     /> <TextView     android:id="@+id/incremental"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     /> <TextView     android:id="@+id/release"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     /> <TextView     android:id="@+id/sdk"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     /> <TextView     android:id="@+id/sdk_int"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     /> </LinearLayout>




No comments:

Post a Comment