get list of running applications

Put your problem here if it does not fit any of the other categories.

get list of running applications

Postby sgoyal111 » Tue Mar 20, 2012 8:31 am

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showapp);
tv=(TextView)findViewById(R.id.listshow);
final ListView lv = (ListView)findViewById(R.id.mylist);



ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);

List l = am.getRunningAppProcesses();
Iterator i = l.iterator();
PackageManager pm = this.getPackageManager();
while(i.hasNext()) {
ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(i.next());
try {
CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA));
Log.w("LABEL", c.toString());
tv.setText(tv.getText().toString()+c.toString()+"\n");


}catch(Exception e) {
//Name Not FOund Exception
}
}
$an Go
sgoyal111
Freshman
Freshman
 
Posts: 2
Joined: Thu Mar 01, 2012 12:05 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests