简体   繁体   English

意图显示正在运行的后台进程

[英]Intent to show running background processes

I have an application that sometimes hits the OutOfMemoryError due to processing a large number of bitmaps. 我有一个应用程序,由于处理大量的位图,有时会遇到OutOfMemoryError I'm catching the error and I want to display a dialog to the user letting them know that they need to kill some background tasks to free up memory. 我正在捕捉错误,我想向用户显示一个对话框,让他们知道他们需要杀死一些后台任务以释放内存。 It would be nice to have a button that opens up an application that does this. 有一个按钮可以打开一个执行此操作的应用程序。

Is there a way to start an Intent that launches: 有没有办法启动启动的Intent:

  • Applications Manager > Running Processes (so the user can force stop some tasks) Applications Manager>正在运行的进程(因此用户可以强制停止某些任务)

  • Or even better the option to choose from any apps the user might have installed that allow you till processes (eg: Advanced Task Manager) 或者更好的选择是从用户可能安装的任何应用程序中进行选择,以允许您进行处理(例如:高级任务管理器)

An even better option would be to automatically clear up background activities but I doubt this is possible. 一个更好的选择是自动清理后台活动,但我怀疑这是可能的。

I have an application that sometimes hits the OutOfMemoryError due to processing a large number of bitmaps. 我有一个应用程序,由于处理大量的位图,有时会遇到OutOfMemoryError。

This means that your own process' heap cannot allocate blocks for your bitmaps. 这意味着您自己的进程'堆不能为您的位图分配块。

I want to display a dialog to the user letting them know that they need to kill some background tasks to free up memory 我想向用户显示一个对话框,让他们知道他们需要杀死一些后台任务以释放内存

Even if it were possible for you to bring up such a dialog, it would be a complete waste of your time and your users' time. 即使你有可能提出这样的对话,也会完全浪费你的时间和用户的时间。 The existence, or lack thereof, of other apps' processes will do nothing about the heap in your own app. 其他应用程序进程的存在或缺乏将对您自己的应用程序中的堆无效。

Is there a way to start an Intent that launches 有没有办法启动启动的Intent

I am not aware of such an Intent . 我不知道这样的Intent

An even better option would be to automatically clear up background activities but I doubt this is possible. 一个更好的选择是自动清理后台活动,但我怀疑这是可能的。

You are welcome, even encouraged, to finish() your own activities when you no longer need them, to free up memory in your heap that the rest of your app can use. 当您不再需要它们时,欢迎(甚至鼓励finish()您自己的活动,以释放您的应用程序的其余部分可以使用的堆中的内存。

This might not solve the issue or suggest what you are looking for. 这可能无法解决问题或建议您正在寻找什么。 But as you are loading large bitmaps and the relevant OOM exception, this link is worth a read 但是,当您加载大型位图和相关的OOM异常时, 链接值得一读

To load the apps screen in the settings, this is the close that you can get 要在设置中加载应用程序屏幕,这是您可以获得的关闭

 startActivity(new Intent(Settings.ACTION_APPLICATION_SETTINGS));

But, why should one close other apps to get your app working. 但是,为什么要关闭其他应用以让您的应用运行起来。 Users would uninstall your app than messing up with your apps mate! 用户将卸载您的应用程序,而不是弄乱您的应用程序伙伴!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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