Sunday, April 14, 2013

[android help] killing other applications

android - killing other applications - Stack Overflow



















i want to kill the sms application when it is open. for this purpose i write a service . that checks if sms application is opened. and if it is then it kills this. i am using ActivityManager class. here is my code but when i launch sms application it nevers ends. why? is it possible ? if yes then please help.



package com.example.activitymanager;

import java.util.List;

import android.app.ActivityManager;
import android.app.IntentService;
import android.content.Intent;
import android.os.Handler;
import android.util.Log;

public class Servicee extends IntentService {
ActivityManager am;
Handler handler = new Handler();
Runnable r = new Runnable() {

@Override
public void run() {
List list = am
.getRunningTasks(Integer.MAX_VALUE);
for (ActivityManager.RunningTaskInfo task : list) {
if (task.baseActivity.getPackageName()
.equals("com.android.mms")) {
am.restartPackage(task.baseActivity.getPackageName());
}
}
handler.postDelayed(this, 5000);
}
};

public Servicee() {
super("");
}

@Override
protected void onHandleIntent(Intent arg0) {
am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
handler.postDelayed(r, 2000);

}

}















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...