kill process - how to force stop all checked application from list view in android programmatically -
in below given code want kill (forcestop) checked applications after restarting application it's showing name of these killed applications again.
i don't know if they're killed or not. why so?
kill.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { //killing selected apps string savedapp; int code = 0; int count = lv.getadapter().getcount(); (int j = 0; j < count; j++) { if (lv.isitemchecked(j)) { intent ints = new intent(intent.action_main, null); ints.addcategory(intent.category_launcher); savedapp = lv.getitematposition(j).tostring(); nm.removeall(nm); // this.l = getlistview(); // l.setchoicemode(listview.choice_mode_multiple); packagemanager pm = getapplicationcontext().getpackagemanager(); list<resolveinfo> intentlist = pm.queryintentactivities(ints, packagemanager.permission_granted); activitymanager am1 = (activitymanager) getsystemservice(context.activity_service); list<runningtaskinfo> processes = am1.getrunningtasks(integer.max_value); if (processes != null) { (int = 0; < processes.size(); i++) { string packagename = processes.get(i).topactivity .getpackagename(); runningtaskinfo temp = processes.get(i); try { pname = (string) pm.getapplicationlabel(pm .getapplicationinfo(packagename, packagemanager.get_meta_data)); } catch (namenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } // int f = 0; if (savedapp.equals(pname)) { // finish(pm.); code = intentlist.get(i).activityinfo .hashcode(); finishactivity(code); am1.killbackgroundprocesses(packagename); am1.restartpackage(packagename); android.os.process.killprocess(temp.id); finishactivity(temp.id); // toast.maketext(this, packagename, // toast.length_short).show(); //f = 1; } else { nm.add(pname.trim()); } } } } } } };//kill button close
Comments
Post a Comment