Search This Blog

Thursday, February 16, 2012

Read AndroidOS version info., using System.getProperty Method

Now this is the another class of reading the android Os version info with the getProperty Method.

Make an .xml file with the following code.


<?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="Android System:"
 />
<TextView
 android:id="@+id/SYSinfo"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 />
</LinearLayout>

Now make the java file for the getProperty method with the following code.



public class OSversion extends Activity{


@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.osversion);
TextView SYSinfo = (TextView) findViewById(R.id.SYSinfo);
    SYSinfo.setText(ReadSYSinfo());
}


private static StringBuffer SYSinfoBuffer;


private String ReadSYSinfo()
{
 SYSinfoBuffer = new StringBuffer();
 
 getProperty("os.name", "os.name", SYSinfoBuffer);
 getProperty("os.version", "os.version", SYSinfoBuffer);
 
 getProperty("java.vendor.url", "java.vendor.url", SYSinfoBuffer);
 getProperty("java.version", "java.version", SYSinfoBuffer);
 getProperty("java.class.path", "java.class.path", SYSinfoBuffer);
 getProperty("java.class.version", "java.class.version", SYSinfoBuffer);
 getProperty("java.vendor", "java.vendor", SYSinfoBuffer);
 getProperty("java.home", "java.home", SYSinfoBuffer);
 
 getProperty("user.name", "user.name", SYSinfoBuffer);
 getProperty("user.home", "user.home", SYSinfoBuffer);
 getProperty("user.dir", "user.dir", SYSinfoBuffer);
 
 return SYSinfoBuffer.toString();
}


private void getProperty(String name, String property, StringBuffer tBuffer)
{
 tBuffer.append(name);
 tBuffer.append(" : ");
 tBuffer.append(System.getProperty(property));
 tBuffer.append("\n");
}
}



Here is the output of the above code



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.