I am getting the following error:
ERROR: The method killBackgroundProcesses(String) is undefined for the type ActivityManager
Now I am dead sure that ActivityManager contains that method http://developer.android.com/reference/android/app/ActivityManager.html#killBackgroundProcesses%28java.lang.String%29.
Here is the code, please help me figure out where I am going wrong?
package com.robosoft.killswitch;
import java.util.List;
import android.app.ActivityManager;
import android.app.ListActivity;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
public class KillSwitch extends ListActivity {
/** Called when the activity is first created. */
private RunningApplicationAdapter runningApplicationAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
final List<ActivityManager.RunningAppProcessInfo> RunningApp = am.getRunningAppProcesses();
runningApplicationAdapter = new RunningApplicationAdapter(this, RunningApp);
//setContentView(R.layout.main);
setListAdapter(runningApplicationAdapter);
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int pos, long id) {
RunningAppProcessInfo x = RunningApp.get(pos);
String y = x.processName;
am.killBackgroundProcesses(x.processName); //Error Here!
}
});
}
}