-
Android 14 - Apps can kill only their own background processes프로그래밍/Android 2023. 5. 31. 11:45반응형
From OS 14 (regardless of targeting OS 14), when your app calls killBackgroundProcesses(), the API can kill only the background processes of your own app.
killBackgroundProcesses (API level 8)
How to kill the background service process:
// manifest <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> // kill the background service process val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager activityManager.killBackgroundProcesses("jp.naver.line.android")
In previous OS versions, It can kill the process of another package name:
// OS9 2023-05-31 16:09:33.231 953-9505 ActivityManager system_server I Killing 2272:jp.naver.line.android:transcoding/u0a143 (adj 900): kill background // OS12 2023-05-31 16:39:27.797 959-5166 ActivityManager system_server I Killing 17228:jp.naver.line.android:transcoding/u0a395 (adj 905): kill background // OS13 2023-05-31 16:45:47.126 1301-2483 ActivityManager system_server I Killing 19459:jp.naver.line.android:transcoding/u0a328 (adj 965): kill background
If you pass in the package name of another app, this method has no effect on that app's background processes, and the following message appears in Logcat:
// OS14 - targets Android 13 or 14 2023-05-31 16:35:11.720 540-917 ActivityManager system_server W Invalid packageName: jp.naver.line.android
Refers
반응형'프로그래밍 > Android' 카테고리의 다른 글
Android 14 - Additional restrictions on starting activities from the background (0) 2023.06.02 Android 14 - Foreground Service types (0) 2023.05.30 Jetpack compose - Custom layout (0) 2022.12.12 Android 13 - Battery Resource Utilization (0) 2022.08.11 Android 13 - Programmable shaders (0) 2022.06.03