Memory usage of application in Android sample code

public class MainClass extends Activity {
ActivityManager activityManager; 
MemoryInfo memoryInfo; 
final String TAG = "MemInfo";
 
 
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
         activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
         memoryInfo = new ActivityManager.MemoryInfo();
 
        activityManager.getMemoryInfo(memoryInfo);
 
    	           Log.i(TAG, " memoryInfo.availMem " + memoryInfo.availMem);
    	           Log.i(TAG, " memoryInfo.lowMemory " + memoryInfo.lowMemory);
    	           Log.i(TAG, " memoryInfo.threshold " + memoryInfo.threshold);
 
  Toast.makeText(getApplicationContext(),  String.valueOf( memoryInfo.availMem), Toast.LENGTH_LONG)
		.show();
 
    } // end onCreate
}
This entry was posted in Android Examples Code and tagged , , . Bookmark the permalink.


Comments are closed.

6,451 views