I want do design App. which will able to detect that the a particular app. is launched and I want to kill it( if it is in a block list). How can I implement this?
Asked
Active
Viewed 121 times
3 Answers
0
Hello you can use the PackageManager clas for this:
List<PackageInfo> pInfos = getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);
for (PackageInfo pInfo : pInfos) {
ActivityInfo[] aInfos = pInfo.activities;
if (aInfos != null) {
for (ActivityInfo activityInfo : aInfos) {
Log.i("ACT", activityInfo.name);
// do whatever else you like...
}
}
}
0
I guess you need to look at the ActivityManager (http://developer.android.com/reference/android/app/ActivityManager.html). This will help you to find the running process. Perhaps this helps:
boolean ProcessRunning(String name) {
ActivityManager manager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List<RunningProcess> processes = manager.getRunningAppProcesses();
for (RunningProcess process : processes) {
if (name.equals(process.name)) {
return true;
}
}
return false;
}
I didn't test this, but this link could also be helpful: Automate closing of applications in Android
0
you can only see the list of launched application and you can not kill other application through own application,because it is handle by OS.

MR. Kumar
- 661
- 8
- 25
-
@GunjanVarma : If I can not kill the app then how can i prevent user to run blocked app ? – Tushar Apr 17 '13 at 15:09
-
@GunjanVarma there is app which is blocking other app."Stay Focused". – Tushar Apr 18 '13 at 07:24
-
@user2208690: what exactly you want can you tell me in detail please? – MR. Kumar Apr 18 '13 at 07:27
-
@GunjanVarma I want to design a App. in which i want to block certain app. in android phone so that user can not run that app. (eg. let my app is "app blocker" and i am blocking "templerun game" app.) – Tushar Apr 18 '13 at 07:44
-
ok now i got,but earlier you didnt have clear your thoughtst, anyway you can do it using package manger to find detail of app and during launching you can check the list of blocking app if it is block list then skip and display message. – MR. Kumar Apr 18 '13 at 14:40
-
Now I managed to block app(temple run) but cant kill it, The app Stay focused is able to kill the app process(temple run) also I would like to know How can it do that ? – Tushar Apr 18 '13 at 14:54
-
you cant kill other application process programmatically. Android not allow to kill other app activity. – MR. Kumar Apr 18 '13 at 17:34