Search code examples
javaandroidandroid-activityandroid-serviceactivity-manager

How can I kill other foreground activity in android?


I want to kill OTHER(NOT ITSELF) foreground activity/service. I checked some methods about kill application.

  1. ActivityManager.restartPackage(String packageName)
    It was deprecated since android 2.2. So I can't use this method.

  2. ActivityManager.killBackgroundProcesses(String packageName)
    I think it only kills background activities. But I want to kill foreground services using startForeground().

Is there any method for killing OTHER foreground activity/service?


Solution

  • I reply myself.

    I rooted my device and used NDK to use shell command.

    And then using NDK, I killed some applications with this command.
    su -c "am force-stop "