简体   繁体   中英

Intent to show running background processes

I have an application that sometimes hits the OutOfMemoryError due to processing a large number of bitmaps. 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:

  • Applications Manager > Running Processes (so the user can force stop some tasks)

  • 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.

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

I am not aware of such an 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.

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

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!

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