Hello everyone, i'm in the process of creating a application manager/ killer for my high school senior project. Unfortunately i'm running into the issue of my view not refreshing graphically with my updated list. The application killing works but the list refreshing after killing the application does not. My application seems to refresh the view when you hit the back button and re-opening my application but hitting the home button and re-opening my application doesn't.
Note - All experimenting has been done on the emulator and not on my Droid yet. My Code: public class NTaskManager extends ListActivity implements DialogInterface.OnClickListener{ //Recreation of RunningAppProcessInfo class that is able to return its process name public class NRunningAppProcessInfo extends ActivityManager.RunningAppProcessInfo{ public NRunningAppProcessInfo(ActivityManager.RunningAppProcessInfo n){ this.importance = n.importance; this.importanceReasonCode = n.importanceReasonCode; this.importanceReasonComponent = n.importanceReasonComponent; this.importanceReasonPid = n.importanceReasonPid; this.lru = n.lru; this.pid = n.pid; this.pkgList = n.pkgList; this.processName = n.processName; this.uid = n.uid; } public String toString(){ return this.processName; } } //Pop up dialog box when user clicks on an item on the list public void onClick(DialogInterface dialog, int which){ String f = String.valueOf(Process.myUid()); if (which == AlertDialog.BUTTON_POSITIVE){ searchAndKillTask(); } else if(which == AlertDialog.BUTTON_NEGATIVE){ Toast.makeText(this, f, Toast.LENGTH_LONG).show(); } } //Declare variables and lists boolean hasNextCheck = true; private static final int REFRESH = 0; boolean isPrevious; boolean isNext; String taskToBeKilled = ""; LinkedList<NRunningAppProcessInfo> processes; //List that will hold object names List<ActivityManager.RunningAppProcessInfo> x; //List containing objects that hold application information ActivityManager z; //Manages applications such as ending them ListIterator<ActivityManager.RunningAppProcessInfo> i; //List iterator ArrayAdapter<NRunningAppProcessInfo> processliststring; ListView lv; AlertDialog.Builder adb; //Alert dialog box builder for clicking of an item /** Called when the activity is first created. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Assign the linked list processes = new LinkedList<NRunningAppProcessInfo>(); //Assign the activity manager z = (ActivityManager)getSystemService(ACTIVITY_SERVICE); //Give the list application information x = z.getRunningAppProcesses(); //Add processes to linked list for list adapter and show it this.refreshList(); //Create an alert dialog box... adb = new AlertDialog.Builder(this); //...If yes kill task... adb.setPositiveButton("Yes", this); //...If no do nothing adb.setNegativeButton("No", this); //When an item on the list is pressed lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //Set text to ask if they want to kill the task adb.setMessage("Kill Task "+ ((TextView)view).getText().toString() + "?"); taskToBeKilled = ((TextView)view).getText().toString(); //Show the alert dialog box adb.show(); refreshList(); } }); } private void refreshList(){ //Clear the list to start fresh processes.clear(); //Refresh the list iterator i = x.listIterator(); //Loop... do{ //Check if there is something next on the list isNext = i.hasNext(); //If there is... if(isNext == true){ //Add the process to the process list processes.add(new NRunningAppProcessInfo(i.next())); } }while(isNext == true);//...while there is something next on the list //Set the list of strings to be used for the listview processliststring = new ArrayAdapter<NRunningAppProcessInfo>(this, layout.ntask_list, (List<NRunningAppProcessInfo>)processes); setListAdapter(processliststring); //View the list of processes lv = getListView(); lv.setTextFilterEnabled(true); } private void searchAndKillTask(){ RunningAppProcessInfo task; i = x.listIterator(); hasNextCheck = i.hasNext(); do{ //Check if there is something next on the list isNext = i.hasNext(); //If there is... if(isNext == true){ //Check if the name matches the task to be killed task = i.next(); if(task.processName == taskToBeKilled){ android.os.Process.killProcess(task.pid); z.restartPackage(task.processName); } } }while(isNext == true);//...while there is something next on the list } /* Creates the menu items */ public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, REFRESH, 0, "Refresh") .setIcon(android.R.drawable.ic_menu_rotate); Toast.makeText(this, String.valueOf(hasNextCheck), Toast.LENGTH_SHORT); return true; } /* Handles item selections */ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case REFRESH: refreshList(); return true; } return false; } } -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en