gogoWebsite

Android gets the currently running thread and the memory used

Updated to 1 hour ago
package ;

 import ;

 import ;
 import ;
 import ;
 import ;
 import ;
 import ;
 import ;
 import ;
 import ;

 public class TastManagerActivity extends Activity {
	 private TextView tv_task_count;
	 private TextView tv_task_memory;
	 private ActivityManager am;
	 private List<RunningAppProcessInfo> runningAppProcessInfoList;
	 @Override
	 protected void onCreate(Bundle savedInstanceState) {
		 // TODO Auto-generated method stub
		 (savedInstanceState);
		
		 am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
		
		 boolean flag = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		 setContentView(.task_manager);
		 if(flag){
			 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,.task_manager_title);
		 }
		 tv_task_memory = (TextView) (.tv_task_memory);
		 tv_task_count = (TextView) (.tv_task_count);
		 //Set the title data
		 setTitleData();
	 }
	 /**
	  * Set the data of the title
	  */
	 private void setTitleData() {
		 /**
		  * If it is of type int, it may be considered id and may report an error
		  */
		 tv_task_count.setText("Number of processes:"+getProcessCount());
		 tv_task_memory.setText("Remaining Memory:"+getAvailMemoryInfo());
	 }
	 /**
	  * Get the number of currently running processes
	  * @return
	  */
	 private int getProcessCount(){
		 runningAppProcessInfoList = ();//Get the running process
		 return ();
	 }
	 /**
	  * Get the available memory information of the current system
	  */
	 private String getAvailMemoryInfo(){
		 MemoryInfo outInfo = new ();
		 (outInfo);//The obtained memory information is put into outInfo
		 long size = ;//The remaining available memory information in the current system Unit byte
		 return (size);
	 }
 }