Android Question Use Reflection to Kill 3rd Process/Service

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
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"

Code: Copy
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
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"

Code: Copy
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
Back
Top