Android 如何以编程方式终止Oreo中的后台任务?
我正在构建一个移动应用程序,我想实现一个功能,在这个功能中,我可以通过删除Android Oreo中的后台任务来清理ram内存,就像CCleaner所做的那样 我尝试了在GitHub上找到的算法。但它似乎只适用于Android 5.0Android 如何以编程方式终止Oreo中的后台任务?,android,android-8.0-oreo,Android,Android 8.0 Oreo,我正在构建一个移动应用程序,我想实现一个功能,在这个功能中,我可以通过删除Android Oreo中的后台任务来清理ram内存,就像CCleaner所做的那样 我尝试了在GitHub上找到的算法。但它似乎只适用于Android 5.0 protected void populateTextViewWithRunningProcesses() { // Empty the TextView mTextView.setText(""); // In
protected void populateTextViewWithRunningProcesses() {
// Empty the TextView
mTextView.setText("");
// Initialize a new instance of ActivityManager
ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
// Get a list of RunningAppProcessInfo
List<AndroidAppProcess> processes = AndroidProcesses.getRunningAppProcesses();
// Display the number of running processes
Toast.makeText(mContext, "Running processes : " +
runningProcesses.size(), Toast.LENGTH_SHORT).show();
// Loop through the running processes
for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) {
// Get the process name
mTextView.setText(mTextView.getText() + processInfo.processName + "\n");
}
}
它只显示我的应用程序自己的任务,而不显示其他正在运行的任务Android 5.0+杀死了getRunningTasksint和GetRunningAppProcess。这两种方法现在都已弃用,只返回应用程序进程。您可以使用UsageStatsManager获取正在运行的应用程序列表。检查此示例:Android 5.0+杀死了getRunningTasksint和GetRunningAppProcess。这两种方法现在都已弃用,只返回应用程序进程。您可以使用UsageStatsManager获取正在运行的应用程序列表。检查此示例:是!我的意思是,我想得到所有其他的任务,像其他应用程序的任务,所以我可以杀死他们一个免费的内存内存!我的意思是,我想获得所有其他任务,就像其他应用程序的任务一样,这样我就可以通过释放ram内存来杀死它们