Android Question Use Reflection to Kill 3rd Process/Service

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi

Does anyone know how to use Reflection to Kill 3rd Party Process/Service

Regards

John.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi Kevin

Thanks for replying to my post. The OS Library does not work for me, neither does phone.shell("kill"....) and ActivityManager lib also.

Permissions is not an issue for the users of this app, I have added in the GET_TASKS, KILL_BACKGROUND_PROCESSES and still no joy. There must be a way for this too work.

Cheers

John.
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
If you can create a B4A library and have the package name of the app that you want to kill its process, you can try this example.
It is just an example for my case, you need to adapt it to your need. What I mean is you have to call the function "killPackageProcesses"

B4X:
public int KillUnwantedProcess() {
      
    List<ResolveInfo> infos = null;
        infos = BA.applicationContext.getPackageManager().queryBroadcastReceivers(intent, 0);
        for (ResolveInfo info : infos) {
            if (info.activityInfo.packageName.contains("unwantedpackagename") == true) {
                boolean result;
                result = killPackageProcesses(info.activityInfo.packageName);
               returns result;
                }
            }
        }
                        
    }

Be aware of that some process is self running, after you kill it, it can restart again.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
If you can create a B4A library and have the package name of the app that you want to kill its process, you can try this example.
It is just an example for my case, you need to adapt it to your need. What I mean is you have to call the function "killPackageProcesses"

B4X:
public int KillUnwantedProcess() {
     
    List<ResolveInfo> infos = null;
        infos = BA.applicationContext.getPackageManager().queryBroadcastReceivers(intent, 0);
        for (ResolveInfo info : infos) {
            if (info.activityInfo.packageName.contains("unwantedpackagename") == true) {
                boolean result;
                result = killPackageProcesses(info.activityInfo.packageName);
               returns result;
                }
            }
        }
                       
    }

Be aware of that some process is self running, after you kill it, it can restart again.
Hi

Thanks for the reply. After much reseach I have discovered that this may not always work, so I cannot use it. The app in question
a system app on a rugged smart phone. I have come with a rather radical solution to achieve the same result.

Many thanks again for taking the time to help.

Regards

John.
 
Upvote 0
Top