package com.example.androidmem;
import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView memInfo = (TextView)findViewById(R.id.meminfo);
String info = "";
info += "Total memory: " + Runtime.getRuntime().totalMemory() + "\n";
info += "Free memory: " + Runtime.getRuntime().freeMemory() + "\n";
info += "Max memory: " + Runtime.getRuntime().maxMemory() + "\n";
memInfo.setText(info);
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:id="@+id/meminfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
![Get memory information thumbnail](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4ZK43HM0J3qsHfJeu0nuRjBJJt3Hrd_eE5pTq7bu6CmmOjW3SpVmIQC65vuXS94wQb6lecmMIH_eY8l8vN0Q34nkU0vHx-lYo7UATD58YZMkg4C1WEN4ZeI9veBhoFHLp_dcScfqdfkQ/s72-c/AndroidMem.png)
Title: Get memory information
Rating: 100% based on 99998 ratings. 10 user reviews.
Post by 11:11 PM
Rating: 100% based on 99998 ratings. 10 user reviews.
Post by 11:11 PM
0 comments:
Post a Comment