Android Question Closing application completely

jnjft

Member
Licensed User
Longtime User
Hello!
I need to exit an app completely from an Activity that is not Main. When I use Activity.Finish this only finishes the running Activity but not the application. ExitApplication however restarts Main. In another thread I found the following solution (posted by Erel):

B4X:
Sub CloseActivities
  Dim jo AsJavaObject
  jo.InitializeContext
  jo.RunMethod("finishAffinity", Null)
End Sub

This works fine, but then the app cannot be started again. I have to close it by hand in 'Recent apps' to be able to restart it.
How can I close it completely?

(I would have posted in the above mentioned thread but there it says one should rather open a new thread.)
 

Cableguy

Expert
Licensed User
Longtime User
have you tried also stopping the starter service?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You should not stop the starter service.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
My suggestion had as a thought logic that, since the starter service is responsible for the app entry point, as well as optionally bars values, and since the op was cleaning the recent apps list, the service was still active but had nothing to call, since the app was no longer in background...
With the extra info from the OP, about the black (empty) activity, then yes, I think it's a problem with the layout loading
 
Upvote 0

jnjft

Member
Licensed User
Longtime User
Are you loading the layout in Activity_create only when firsttime is true? If yes; load it everytime..
No, I don't use firsttime, I'm loading the layout everytime the activity is created.
 
Upvote 0

jnjft

Member
Licensed User
Longtime User
I'm sorry folks - I was loading Main everytime, alas it has no layout but it starts another activity if firsttime. I now start this activity everytime and it works!
Thanks a lot for your efforts everybody!
 
Upvote 0
Top