Android Question Exit from application in clean way

Kunhock Koo

Member
Licensed User
To exit and close my B4A application, I have tried all methods I can think of like exitApplication etc. But the app is always still there waiting pounce back. Can someone kindly advise .. greatly appreciated

Thank You

Kunhock
 

khwarizmi

Active Member
Licensed User
Longtime User
As far as I know, exitApplication closes the application when applied from the only one active view, try to close every activity with acttivity.finish then you can apply exitApplication from the last one.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I write this just to make me tease :D

To definitively close an app, I thought it was enough to close all the Activities and stop all the Services.

Until, very recently, despite my "experience", that... it is not possible to stop the Starter service (I guess it's a protection set by Erel).
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Try this
B4X:
Sub CloseActivities
 Dim jo As JavaObject
 jo.InitializeContext
 jo.RunMethod("finishAffinity", Null)
End Sub
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
As far as I Know, the App only "dies" when the OS decides to "kill" it in order to free resources.
All other "methods" only let the OS know that the app is no longer in active use.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
The method that I suggested closes all the activities in case the app has opened more than one and prevents the operating system from restarting the app believing that it has been interrupted by mistake.

But it always remains in the task manager except you set it to not appear entirely on the task manager Grom Manifest.

See this thread
https://www.b4x.com/android/forum/threads/closing-an-app.93221/#post-589867
 
Last edited:
Upvote 0
Top