HardCoder
HardCoder

Reputation: 3036

How can I stop the service of another app in Android?

On my device runs a service in an app (its not my app and I cannot uninstall it and my device is not rooted) that is always draining power. I can stop that service in my devices application settings but is there a way to stop it programatically, so I don't have to do that manually all the time ?

Could maybe something like stopService(...); work ?

Is there maybe a way to change the scheduler to prevent the restarts of the service ?

"W/ActivityManager(178): Scheduling restart of crashed service xxxx in 5000ms

Upvotes: 6

Views: 1739

Answers (2)

Jambaaz
Jambaaz

Reputation: 2848

Get the process id of that particular application and then

android.os.Process.killProcess(processIdKillService)

Upvotes: 1

avimak
avimak

Reputation: 1628

Here is a long shot (I've never tried it):

  1. Create a Context instance for that app using Context.createPackageContext()
  2. Use it to stop the service via Context.stopService()

Upvotes: 0

Related Questions