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);
}
}
No comments:
Post a Comment