1

I am working on a legacy project. This Android app was a system app installed in a specific tablet model with a customized Android operative system. The user only had access to this app, he couldn't access any other features of the tablet. So only this app was on the screen.

Now, the customer want to open the app to smartphones and I'm doing this update. I realized that when I close the app manually (swiping up from open apps screen) the process is still alive. I can see this running ps -A | grep myAppName command in the shell, even after several minutes. I tried with other apps and the processes disappeared when the apps are closed.

In the onDestroy method of the MainActivity (the launcher activity) I do these things:

  • Stop all services with stopService(new Intent(this, MyService.class));.
  • Stop some Timer objects.

I don't know what other components can keep the app active. The app has BroadcastReceivers and a LifecycleObserver but I don't know if some of them could be the reason. I know that Android keeps in memory the apps and kills them when it is necessary, but I think that this example is not that case. Do you have any ideas on this?

Jon
  • 891
  • 13
  • 32
  • Keep in mind that it's very dangerous to kill apps. check this. https://stackoverflow.com/q/13847502/10778405 – S T Sep 02 '20 at 06:13
  • I only want to be sure that I don't have any Thread running in my own app, I don't want to close other app. Closing my app from "recent apps" isn't dangerous, otherwise it wouldn't be accessible to all Android users. – Jon Sep 02 '20 at 06:33

1 Answers1

1

how about add this code in your onDestroy function?

 System.exit(0);
S T
  • 1,068
  • 2
  • 8
  • 16