Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Possible Duplicate:
How can I stop applications and services from running?

There is already a similar question to this one, but mine is narrower in scope and not addressed in the other question:

Consider the case of an app that meets the following criteria:

  1. Let's take a file manager as an example, but it could be a different app just as easily. The specific app isn't important to this question.
  2. This app has no legitimate need to run in the background. I only need file management when I'm actively using the app. (In case my specific example does turn out to have a need, suppose for the sake of the discussion that it actually doesn't.)
  3. The fact that it runs in the background is confirmed by a system monitor.
  4. Even though I believe that it has no legitimate need to run in the background and don't want it to do so, I don't want to uninstall it.

Can I prevent such an app from running in the background?

Practical application

To illustrate the need for this specific question, and why I'm not naming specific apps, consider what I had in mind when I wrote this question:

I would like to go through my apps and decide which ones I want to run as services. Some should run without restrictions. Some should never run. Some should only run when some set of conditions is met. Using the information from an answer to this question, I could implement this--possibly by some custom scripting, possibly using Tasker, or possibly using another approach. Trying to handle this via each individual app's settings would be well-nigh impossible.

Of course, if what I'm asking in this question isn't possible, then this application of it isn't viable.

Notes based on the comments and answers

  • The reason why I want to do this is irrelevant. Perhaps it's to save battery. Perhaps it's another reason. This question is about how, not why. A warning that a particular solution could have negative side-effects is useful if presented along with that solution. Saying, "It's impossible" is legitimate if true. Saying "Don't do it" isn't useful.
  • This is not a duplicate of the question I linked to in my first paragraph. That question was about saving memory. This one isn't. That one said, basically, "Don't try." That's not a valid answer to this question.
  • The specific apps are unimportant, which is why I was vague. I did give a hint as to a specific example I had in mind, but I'm looking for a general answer here.
  • A solution must also prevent an app from automatically restarting; otherwise, it isn't much of a solution.
  • A number of people have stated that this is a duplicate. Let me try to explain more clearly why it isn't:
    1. This question is about how to prevent an app from running in the background, which includes stopping it from restarting if killed.
    2. The answers so far have fallen into a few general categories:
      1. You shouldn't try, because doing so is unnecessary. I'm not disputing this point at this time, but "You shouldn't try" is very different from "You can't." Logically, it's addressing a different question, namely "Should I try to kill apps that I don't want to run?"
      2. Use method X to kill the app. Unfortunately, when I tried said method, it didn't prevent the app from restarting, just like others predicted. So, it isn't really an answer.
      3. Ping the developer/it's a bug. This is the most useful of the suggested solutions, but my question was looking for a generic solution.
    3. The other questions that this question has been said to be a duplicate of cover the same ground as in my previous point. Thus, my specific question has not been addressed, despite many claims to the contrary. It's appearing, however, that the answer is a simple "You can't".
    4. There's a related question on meta. In Jeff Atwood's answer, he says in part, "It's generally sufficient to link to the other question and explain why it doesn't meet your needs." The whole thread is apropos to this question. I've done this since the beginning, and provided further details in subsequent edits.
share|improve this question

marked as duplicate by Matthew Read Oct 3 '12 at 23:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
As this is not a real answer I'll just comment: many custom ROMs have a function to make a long press of the back button completely shut down any active app. I frequently use this to quit apps that I want gone completely until I open them next time. Other than that, it's good to know that background apps shouldn't affect your battery life. –  bigbadonk420 Oct 1 '12 at 16:49
2  
Your question is a duplicate of too many questions; it is not narrower in scope, you're just spelling out what many others didn't. Saying it isn't a duplicate didn't make it not a duplicate. The solutions always fell into three categories: 1) use task killer, 2) uninstall the app, or 3) disable the service in the app. There are also many questions discussing pros and cons of task killers. At this point, I don't see anything in this question that hasn't already been discussed in other threads. Please be more specific, managing background task can only be decided on case-by-case basis. –  Lie Ryan Oct 2 '12 at 10:38
    
@LieRyan: See my edit above, where I explain how this is, indeed, a different question. –  Scott Severance Oct 2 '12 at 11:26
1  
I think we need some canonical question of that type. The duplicates 1, 2, from 3 don't fall into that category. I propose to migrate the answers from 3 here and mark it a duplicate. –  Flow Oct 2 '12 at 13:37
    
The simple flow of the activity life-cycle, which is documented over on Google's developer pages, and employed and used by a large majority of developers, What you're coming across is this how can I control an app that a developer has made, to prevent it from going into the background - you cannot! The developer may have made a design decision over the life-cycle and used a service instead! But this question is moot as you're not being specific and dodging the true question - what apps are you referring to? –  t0mm13b Oct 2 '12 at 14:22

4 Answers 4

up vote 3 down vote accepted

tl;dr

It's ok if the app in background is just an activity. Activities just consume some memory are usually not able to run computations in the background. Therefore no CPU or battery is used for them. But if the app in background is running a service:

Ping the developer

Ping the developer! One of the greatest daemons that come with Android are Services that run in background for no reason or when a simply interval check with Android's AlarmManager would be sufficient. We need to kill them all with fire and not by ignoring them. Everything that does not involve a fix by the developer is just a dirty hack that by experience will result in other negative side-effects.

Activities that run in Background

Pure Android apps and their activities usually stay around in memory for a while after they were put out of view. But at some point they may get deleted by Android's ActivityManager if there is an ongoing memory pressure. This is intended behavior, we (the users) want it that way and it works good in recent Android versions. Therefore there is nothing wrong if you see your file manager hanging around in memory.

Services that run in background

But, if it's a service that you see running forever without apparent reason (and without the possibility to disable the service somewhere in the Apps settings), you should contact the developer. In 99% of all cases, there is no reason to waste your precious memory by doing so. Android provides with intents and the already mentioned AlarmManager enough facilities to avoid long running services. Sometimes developers will response with "but Google Maps does that too". I argue that this is never an excuse to point at others, plus it doesn't provide a valid reason to run a background service.

share|improve this answer
    
Thanks for your answer. It provides food for thought. –  Scott Severance Oct 2 '12 at 11:34
1  
Good explanation and to the point, +1 from me. I'm just mad you stole my Google-Maps-Argument xD In too many cases, Google itself gives the worst examples (see e.g. background sync settings, which are permanently ignored by several Google apps, and other "background activities" which are not configurable -- I could sing a long song about those...). –  Izzy Oct 2 '12 at 12:40

Can I prevent such an app from running in the background?

You're refusing to accept the answers you're getting because you don't think they fit, but they do. Your question is how to stop apps automatically instead of letting them run in the background. The answer you're getting is that in most cases this is unnecessary and completely bypasses the way Android is created to deal with background apps.

There's plenty of apps available to kill apps in the background, you can also swipe them away or you can use short commands like "long press back" in certain roms to shut down the process. Very rarely however is this to be expected from the user; a misbehaving app should be reported first of all, instead of being worked around.

If an app has "no legitimate need to run in the background", but it is still using system resources (please make sure this is actually true), then that app is poorly designed. It's not a fault in the Android operating system.

That being said, there are plenty of ways to shut down apps manually. Doing it automatically makes no sense, most apps behave well.

share|improve this answer
    
You correctly summarized my question and a commonly-stated position. But there's a logical problem here. The answer "It's not necessary" logically doesn't answer the question "How can I..." See my edit to my question for more. –  Scott Severance Oct 2 '12 at 11:24
1  
It's counter-productive to answer questions that likely build on a misunderstanding. It's like expecting an answer to the question "how do I copy files with the dd command" and then refuse to accept that cp is a better alternative. I can see the point of answering every question from a learning perspective, but we also don't want to confuse people coming into the question externally via searches and so on. –  bigbadonk420 Oct 3 '12 at 21:38
    
@bigbadonk420 - good point, questions with an invalid premise often can't really be answered. But your example is an odd one, given that a stock android install has a dd command but lacks a cp one ;-) –  Chris Stratton Oct 13 '12 at 3:25

Use Llama, an app that can automate many things including killing an app when you go to a different app. It does require root to kill apps.

Create a new Event. Add the condition called Active App, and choose the status App stopped or in background. Choose the app you want to focus on.

Next, add an Action. Select Kill Application (root privileges), then select your app again.

Now, whenever you leave the app, Llama will kill it.

Note that the app may have other ways of starting, such as starting on boot or recieving a text or any other Intent that it handles. To keep it from handling those Intents, use the app Permissions Denied, or use a custom rom like CyanogenMod that have the ability built in. These apps can revoke permissions for any app (again, root required).

Edit: It looks like the free version of Permissions Denied is no longer available. I can still access the google play page (because I have it installed), but it's gone for new users. The paid version is still there, though.

share|improve this answer
1  
Not recommended to be killing apps that run in the background, especially services, as that will instantly restart and suck up battery juice... just my 2cents. ;) –  t0mm13b Oct 1 '12 at 19:42
    
The OP doesn't specify what apps they desire to be killed. Killing Facebook, for example, will save battery life, since it won't be checking for updates. And it won't automatically restart; only some services are able to do that. There are situations where killing an app is good. –  Stephen Schrauger Oct 1 '12 at 19:50
    
I used Permissions Denied on my previous phone once. When it started up, it immediately started making changes I hadn't asked for and destabilized my phone. I won't be using that app again. –  Scott Severance Oct 2 '12 at 3:24
1  
Thanks for the answer. Since I'm a Tasker user, I set up an equivalent configuration. However, it didn't prevent my test app from restarting. –  Scott Severance Oct 2 '12 at 3:25

If you are running ice cream sandwich or jellybean you can go into settings hit apps and manually shut down the app by tabbing over to the running apps. Alternatively you can hit the recent app button and swipe them of the screen. However this method wont get all background processes.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.