Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Kill running applications from list

Kill running applications from list

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

Kill running applications from list

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

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_item_list);
listview=(ListView)findViewById(R.id.mylist);
final ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);

List l = am.getRunningAppProcesses();
final Iterator i = l.iterator();
final 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());
s+=c.toString()+"~";
Log.d("s isssssss",s);
values=(s.substring(0, s.length()-1)).split("~");
//tv.setText(tv.getText().toString()+c.toString()+"\n");


}catch(Exception e) {
//Name Not FOund Exception
}
}
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
listview.setAdapter(adapter);
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//compstr=listview.getItemAtPosition(position).toString();

//Toast.makeText(getApplicationContext(),listview.getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
closeapp(listview.getItemAtPosition(position).toString());
Log.d("function called","CALLED");
//Toast.makeText(getApplicationContext(),"You have entered: "+edt.getText(), 2000).show();

}
});

} void closeapp(String app)
{
final ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);

List l = am.getRunningAppProcesses();
final Iterator i = l.iterator();
final PackageManager pm = this.getPackageManager();
compstr=app;
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());
//tvt.setText(tvt.getText().toString()+c.toString()+"\n");

if(c.toString().equals(compstr)) {

//Toast.makeText(getApplicationContext(), compstr+" App is running", Toast.LENGTH_LONG).show();
Log.w("COMPLETE", "TARGET APPLICATION IS RUNNING");
//ends the process
am.restartPackage(info.processName);
//Toast.makeText(getApplicationContext(), compstr+" App is closed successfully", Toast.LENGTH_LONG).show();
Toast toast = Toast.makeText(getApplicationContext(),compstr+" App is closed successfully", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
LinearLayout toastView = (LinearLayout) toast.getView();
ImageView imageCodeProject = new ImageView(getApplicationContext());
imageCodeProject.setImageResource(R.drawable.recycleapp);
toastView.addView(imageCodeProject, 0);
toast.show();
//Intent inttn=new Intent(Listtokill.this,RunningappsActivity.class);
//startActivity(inttn);
}



}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: Google [Bot], Yahoo [Bot] and 8 guests