Example:
package com.example.androidgetrunning; import java.util.List; import android.support.v7.app.ActionBarActivity; import android.text.method.ScrollingMovementMethod; import android.app.ActivityManager; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> list = activityManager.getRunningAppProcesses(); StringBuilder info = new StringBuilder(); info.append("android-coding.blogspot.com" + list.size() + "\n\n"); info.append("no. of running application processes: " + list.size() + "\n"); for(int i=0; i<list.size(); i++){ info.append(list.get(i).processName + "\n"); } TextView texView = new TextView(this); texView.setMovementMethod(new ScrollingMovementMethod()); texView.setText(info); setContentView(texView); } }
No comments:
Post a Comment