'Read Android system info.'에 해당되는 글 1건

  1. 2010.05.04 Read Android system info., using System.getProperty 1
04.Anddoid2010. 5. 4. 14:07
반응형

Sunday, September 6, 2009

Read Android system info., using System.getProperty

It's another exercise to read Android system information, using system provided method getProperty.



Create a new Android Application, with the Activity named AndroidSYSinfoActivity. Modify the main.xml and AndroidSYSinfoActivity.java:
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:gravity="center_horizontal"
android:text="android-er.blogspot.com"
android:autoLink="web"
/>
<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>

Download main.xml.

AndroidSYSinfoActivity.java
package com.exercise.AndroidSYSinfo;

import com.exercise.AndroidSYSinfo.R;

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

public class AndroidSYSinfoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


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 desc, String property, StringBuffer tBuffer)
{
tBuffer.append(desc);
tBuffer.append(" : ");
tBuffer.append(System.getProperty(property));
tBuffer.append("\n");
}
}

Download AndroidSYSinfoActivity.java.


출처 : http://android-er.blogspot.com/2009/09/read-android-system-info-using.html
Posted by 1010