Android Tutorials - Herong's Tutorial Examples - v3.05, by Herong Yang
System.getProperties() - Retrieving System Properties
This section provides tutorial example on how to use the java.lang.System.getProperties() method to retrieve and display Android system properties.
After practiced the build, install and run Android application process, I want to obtain Android system properties through the java.lang.System class.
1. Enhance my application to print out system properties by editing .\src\com\herongyang\AboutAndroid.java
/* AboutAndroid.java * Version 2.0 - Displaying system properties * Copyright (c) 2015, HerongYang.com, All Rights Reserved. */ package com.herongyang; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class AboutAndroid extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String msg = ""; msg += "System properties\n"; msg += "-------------\n"; java.util.Properties props = System.getProperties(); java.util.Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { String k = (String) e.nextElement(); String v = props.getProperty(k); msg += k+": "+v+"\n"; } TextView tv = new TextView(this); tv.setText(msg); setContentView(tv); } }
2. Uninstall the previous version by running "ant uninstall" command.
3. Build, install and run the application again on the emulator. Some system properties are displayed:
But there is problem with the display, the screen does not have enough space to display all properties, and you can not scroll down screen to see more properties. In the next tutorial, I will try to design a scrollable view.
Table of Contents
Installing JDK 1.8 on Windows System
Installation of Android SDK R24 and Emulator
Installing Apache Ant 1.9 on Windows System
Developing First Android Application - HelloAndroid
Android Application Package (APK) Files
Android Debug Bridge (adb) Tool
►AboutAndroid - Application to Retrieve System Information
java.lang.System Class - Accessing System Information
Creating Android Project for Simple Application
Build, Install and Run Android Application
►System.getProperties() - Retrieving System Properties
android.widget.ScrollView Class - Scrolling Text View
System.getenv() Method - System Environment Variables
android.os.Environment Class - Environment Folders
android.content.Context - Application Context Information
android.app.Activity Class and Activity Lifecycle
View Objects and Layout Resource Files
Using "adb logcat" Command for Debugging
Build Process and Package File Content
Samsung Galaxy Tab 3 Mini Tablet
USB Debugging Applications on Samsung Tablet
USB Debugging Applications on LG-V905R Tablet