Thursday, 10 March 2011

android code to get the kernel version.....

1:We use the function "System.getProperty("os.version")" to get the kernel version.
2:If we write "os.name" in place of "os.version" in the above function we get the name of the os. i.e,Linux.
3:The complete code is given below:

kernelinfo.java
package com.example.kernelinfo;

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

public class kernelinfo extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText(System.getProperty("os.version"));
       setContentView(tv);
   }
}



main.xml
<?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"
    />
</LinearLayout>

4:This is the default main.xml file.

No comments:

Post a Comment