30

When I go to Settings > Applications > Manage Applications > Downloaded I see an application list. If I select some applications I see button "Force stop" active, but some applications have this button dimmed.

What does it mean? What happens if I press this button?

This button can't mean application running, since the applications with this button are not listed in Running section.

Can I list just applications which have the Force stop button active and uninstall them?


Android version: 3.2

4 Answers 4

18

As said in my comment to paco's answer, the information he gave is mostly correct: Most apps don't exit completely if you leave them, and no app should exit if you leave it via the "Home" button. Moreover, some apps have background services running which the user otherwise cannot quit.

Now there are some situations where you need an app (including its background services) to be stopped -- e.g. if you want to uninstall that app (or, in case of a system app, its updates). You will notice this when the "Force Stop" button is active, the "Uninstall" (or "Remove") button is grayed out -- but the latter gets activated when you stopped the app via "Force Stop". (If both buttons are grayed out, you can tell it's a system app, by the way -- which you cannot uninstall).

Btw: If the "Force Stop" button is grayed out ("dimmed" as you put it) it means that app is not currently running, nor has it any service running (at that moment).

2
  • 1
    You will notice this when the "Force Stop" button is active, the "Uninstall" (or "Remove") button is grayed out, can you give an example app which is having this behaviour? I just skimmed through some of my apps and found that both "Force Stop" and "Uninstall" buttons are activated. I am on Android 4.4.2.
    – cychoi
    Commented Dec 1, 2014 at 11:19
  • 1
    As my answer is already 2 years old, Kitkat was not available back then; this behavior might have changed or not affecting all apps. I cannot test with Kitkat (no device running that), and out-of-my-head do not remember which packages I've seen that with, sorry.
    – Izzy
    Commented Dec 1, 2014 at 11:32
17

The code behind the Force stop button is complex and undocumented. I'll reproduce it verbatim and then go through it one piece at a time.

private void checkForceStop() {
    if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
        // User can't force stop device admin.
        updateForceStopButton(false);
    } else if ((mAppEntry.info.flags&ApplicationInfo.FLAG_STOPPED) == 0) {
        // If the app isn't explicitly stopped, then always show the
        // force stop button.
        updateForceStopButton(true);
    } else {
        Intent intent = new Intent(Intent.ACTION_QUERY_PACKAGE_RESTART,
                Uri.fromParts("package", mAppEntry.info.packageName, null));
        intent.putExtra(Intent.EXTRA_PACKAGES, new String[] { mAppEntry.info.packageName });
        intent.putExtra(Intent.EXTRA_UID, mAppEntry.info.uid);
        intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(mAppEntry.info.uid));
        getActivity().sendOrderedBroadcast(intent, null, mCheckKillProcessesReceiver, null,
                Activity.RESULT_CANCELED, null, null);
    }
}

The first if line checks if any component of the package is a device admin (that is, if it's checked in the Device administrators list in the Security page of the Settings app). If so, the button is disabled (greyed out) so you can't stop device admins.

Then, the else if checks if the package is already stopped. Here, stopped doesn't just mean "not running". As far as I can tell, a package is in the stopped state if you've never run any component from it (such as by launching it from the menu), or if you've pressed a Force stop button (this one or in a "stopped working" dialog) and not run any of its components again. If the package hasn't been stopped, the button is enabled.

The else case covers the rare eventuality that an app has been stopped and isn't a device admin. In this case, it gives other system services a chance to enable the button. For example, the app might have an alarm set and pending, which would later cause the app to be started again even from the stopped state. In this case, the button will be enabled. If no other system service has a reason to enable the button, it will be disabled.

Summary

The Force stop button is enabled if the package is not a device admin and either you haven't already force-stopped this app or you have force-stopped it but a system service thinks it will run it again.

If the app is running (and it isn't a device admin), the Force stop button will definitely be enabled, but the button being enabled doesn't mean the app is running.

1
  • 1
    It's great that you show us the code that determines whether the button is displayed or not. To a developer like me that is the perfect answer. But really, this is only half the answer. You don't show what happens when you actually press the button. Commented Feb 25, 2019 at 14:08
2

Android maintains 4 types of applications in its memory. I dont remember all but running and cached background are 2 of them...(cached background can be accessed by clicking the hardware menu button when in the running tab and selecting the poped up option)

So though it might not be seen in the running processes, it is not entirely dead.

Mostly it shall be in the cached background prcesses.

also, about task managers..Its is not advised to use them as android has been hardcoded to manage apps efficiently.App/Task killers actually rather drain battery as after the killer kills apps, acording to the algorithm android follows,they will be started again!(and apps take up rather more memory at startup than in ideal state) thus it becomes a cycle and drains the battery.

so the force close button is active on mostly running and cached processes and may exist on a very few apps that reside in the other two types of processes!

on other apps its greyd out!

1
  • 1
    It's more than 4 types (see Understanding Android Application and Activity Lifecycles for a closer explanation). But those classes have nothing to do with the "force stop" button, at least not directly (see my answer: an active "force stop" button simply means that either the app itself or one of its registered services is currently running).
    – Izzy
    Commented Nov 21, 2012 at 10:51
-2

This button is active for apps that are running or are be running since the last time that you started your device.

Android do not kill the apps totally when you exit from it, this button is for close completely the app and remove it from the stack (apps running), also this button free the memory used by the app.

There is no way to list the apps running, also the apps running in background have this button.

There are free killer apps in the Play Store, to manage the memory of your device automatically.

1
  • 3
    While the basic information is correct: better remove the part about the "automatic killers". There might have been some time when they were needed (before Android 2.x), but they are absolutely contra-productive and mostly have a negative effect on battery runtime.
    – Izzy
    Commented Nov 20, 2012 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .