Feb 6, 2011

Get Android OS property using System.getProperty(String)

System.getProperty(String propertyName) returns the value of a particular system property or null if no such property exists.

Android OS property

package com.GetOsInfo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class GetOsInfo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView arch = (TextView)findViewById(R.id.arch);
TextView name = (TextView)findViewById(R.id.name);
TextView version = (TextView)findViewById(R.id.version);
arch.setText("os.arch: " + System.getProperty("os.arch"));
name.setText("os.name: " + System.getProperty("os.name"));
version.setText("os.version: " + System.getProperty("os.version"));
}
}


<?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/arch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/version"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>


1 comment:

Infolinks In Text Ads