If you want to view the specific system information in the Android mobile operating system, such as the memory size and system performance. What is the specific operation method? Here, we can fully master this operation method to facilitate our understanding of this mobile phone system.
Today, we will talk about how to view the mobile phone attributes, memory usage, and other information in the Android system information, which has become a household name on the Android system. What about Android? In fact, it is also very simple, just look at the following code.
- Package com. srk. study. system;
- Import android. app. Activity;
- Import android. app. ActivityManager;
- Import android. widget. TextView;
- /**
- * Gphone Test Tool
- * @ Author shenrenkui
- */
- Public class SystemProperty extends Activity {
- /**
- * Display the Data Inventory
- */
- Private StringBuffer buffer;
- @ Override
- Protected void onStart (){
- Super. onStart ();
- InitProperty ();
- GetMemoryInfo ();
- TextView TV = new TextView (this );
- TV. setText (buffer. toString ());
- This. setContentView (TV );
- }
How to view Android system information
- private void initProperty() {
- initProperty("java.vendor.url", "java.vendor.url");
- initProperty("java.class.path", "java.class.path");
- initProperty("user.home", "user.home");
- initProperty("java.class.version", "java.class.version");
- initProperty("os.version", "os.version");
- initProperty("java.vendor", "java.vendor");
- initProperty("user.dir", "user.dir");
- initProperty("user.timezone", "user.timezone");
- initProperty("path.separator", "path.separator");
- initProperty(" os.name", " os.name");
- initProperty("os.arch", "os.arch");
- initProperty("line.separator", "line.separator");
- initProperty("file.separator", "file.separator");
- initProperty("user.name", "user.name");
- initProperty("java.version", "java.version");
- initProperty("java.home", "java.home");
- }
- private void initProperty(String description,
String propertyStr) {
- if (buffer == null) {
- buffer = new StringBuffer();
- }
- buffer.append(description).append("--->:");
- buffer.append(System.getProperty(propertyStr)).
append("\n");
- }
View memory in Android system information
- Private void getMemoryInfo (){
- Final ActivityManager activityManager =
(ActivityManager) getSystemService (ACTIVITY_SERVICE );
- ActivityManager. MemoryInfo outInfo =
New ActivityManager. MemoryInfo ();
- ActivityManager. getMemoryInfo (outInfo );
- Buffer. append ("\ n remaining memory: ---->"). append
(OutInfo. availMem> 10). append ("k ");
- Buffer. append ("\ n remaining memory: ---->"). append
(OutInfo. availMem> 20). append ("M ");
- Buffer. append ("\ n is in the low memory status: -----> ").
Append (outInfo. lowMemory );
- }
- }
By the way, the Android system also provides the Runtime class, but the information obtained by this class is the usage information of the Java Virtual Machine. The preceding section describes how to view Android information.