Android Question Closing an App

elitevenkat

Active Member
Licensed User
Longtime User
I had tried
B4X:
Activity.Finish

i tried this code by Erel but the app remains open. Any other method to close the app complete ?

B4X:
public  Sub CloseAll
    Dim jo As JavaObject
    jo.InitializeContext
    jo.RunMethod("finishAffinity",Null)
  
End Sub

Multiple activities and 2 services are being run,
 

elitevenkat

Active Member
Licensed User
Longtime User
Thanks for the reply. I think I have not put my question clearly.

Actually I want to close my own runnkng app having multiple activitirs and 2 services and not any other running app. The app seems to be getting closed but remains in the back ground. It does not go away from the device memory.

The link you had reffeted seems to explain about closing another running app.
 
Upvote 0

johndb

Active Member
Licensed User
Longtime User
Thanks for the reply. I think I have not put my question clearly.

Actually I want to close my own runnkng app having multiple activitirs and 2 services and not any other running app. The app seems to be getting closed but remains in the back ground. It does not go away from the device memory.

The link you had reffeted seems to explain about closing another running app.
Add this to the manifest.
B4X:
SetActivityAttribute(Main, "android:excludeFromRecents", "true")
 
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
For Android 5+ (SDK 21+)
B4X:
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethod("finishAndRemoveTask", Null)
Thanks for your reply.
Mine is android 7 and sdk 27. This gives error
java.lang.RuntimeException: Method: finishAndRemoveTask not found in: com.eoos.android.main
 
Upvote 0
Top