简体   繁体   中英

How can I close background processes from my Android app?

I am developing an Android application. How can I close a background process like a music player or video player?

As of Android 2.2 and above you can only kill background processes. If you want to kill a background process you can use the following:

private ActivityManager actman = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
actman.killBackgroundProcesses("com.root.package");

also your android manifest must include the permission:

android.permission.KILL_BACKGROUND_PROCESSES

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM