Activity.finish() called but activity stays loaded in memory

When I run my app on the debugger, I get the main thread and 3 binder threads.

On a button click I call Activity.finish(), which looks like it ends the activity as the UI closes and goes back to the home screen.

  • Suppress / Block BroadcastReceiver in another app
  • Launch main activity if activity stack is empty
  • What permission I need in order to use camera flash in camera preview?
  • How to enable/disable toolbar scrolling programmatically when using design support library
  • How to remove comments in raw XML files with Gradle when the file is packaged
  • Android Widget using Cordova
  • However, in the debugger, it still shows the main thread and 3 binder threads as “(running)“.

    I am baffled to why this is happening. Even more so, it is causing my app to call Activity.onResume() when I run it again after exiting the app.

    I currently override these methods in the Activity, but I call the appropriate super functions in each one:

    • onDestroy()
    • onPause()
    • onResume()
    • onSaveInstanceState()

    Any help or advice regarding this is much appreciated!

    Related posts:

    Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;
    How to install an APK file on an Android phone?
    Ionic Android build: java.lang.IllegalStateException: buildToolsVersion is not specified
    Trouble debugging android wear over bluetooth - Unable to connect to localhost
    Have a disabled onClick?
    LinearGradient Center Animation
  • How to create a view that is bigger than the screen?
  • TableLayout - Remove space between columns
  • Views above and below RecyclerView
  • Android loopj asynchttpclient return response
  • android ANTLR make not working properly
  • CancellationException when using ExecutorService
  • One Solution collect form web for “Activity.finish() called but activity stays loaded in memory”

    You don’t control when your app leaves main memory, the OS does. Look closely at Activity.finish…

    Call this when your activity is done
    and should be closed. The
    ActivityResult is propagated back to
    whoever launched you via
    onActivityResult().

    Note that is says nothing about memory. As to calling Activity.onResume, that’s exactly what you would expect for the lifecycle; remeber that onResume is not just called after a resume but even when the app is first launched after onCreate.

    While not exactly what you asked I suggest you read this article about exit buttons which goes on to say something very important

    [Activity.finish] is exactly equivalent to hitting the back button.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.