Android Question Returning from an activity terminates app

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I started to create a new app with the current version of B4A and noticed that using Activity.Finish closes the other activity and does not display the main activity that called the other activity. The app terminates without displaying the main activity and the Sub Activity_Resume coding never executes upon closing the other activity. I'm not sure why this happens. The same thing happens when I tap the "Back" button on my phone as well.

This is the first time this has happened to me.

I'm using this code to call another activity:
B4X:
Sub CustomViewSettings_Up()
    StartActivity(Settings)
End Sub

I'm using this code to return to the main activity from the other activity because Activity.Finish is not working:
B4X:
Sub CustomViewExit_Up()
    StartActivity(Main) 
'    Activity.Finish
End Sub

This coding calls the main activity but I'm afraid that if the user keeps going back and forth between the main activity and the other activity, memory will eventually run out of the Android device they are using.

I'm using this coding in the Activity_Resume of the main activity:

B4X:
    ' Neatly arrange views.
    '----------------------
    Utils.CenterViewOnBottom(CustomViewExit, PanelMenu, 75)
    Utils.CenterViewOnBottom(CustomViewDisable, PanelMenu, 250 )
    Utils.CenterViewOnBottom(CustomViewEnable, PanelMenu, 425)
    Utils.CenterViewOnBottom(CustomViewSettings, PanelMenu, 600)
   
    bm.Initialize(LoadBitmap(File.DirAssets,"Settings.png"))
    CustomViewSettings.setIcon(False,bm)

I also commented this coding out just to make sure it was not causing a problem.

Thanks.
 
Last edited:

JonPM

Well-Known Member
Licensed User
Longtime User
Are you able to recreate the problem in a small project and upload it here?
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Jon,

I'm going to upload a test app.

Here are the steps I took to duplicate the problem:

Place the gui in release mode.
Compile and install the app. (Do not exit the installer after installing the app.)
Tap the open button when the installer finishes installing the app.
Tap the settings button on the app to display the settings screen.
Tap the exit button from the settings screen.
You can repeat going back and forth between those two screens without a problem.
Now exit the app all together by tapping the exit button from the main screen.
Go to your phone's apps screen and launch the test app.
Go to the settings screen from the test app.
Try to go to the main screen by tapping the exit button or even the back button on your phone.
The app will terminate and not display the main screen.

You can get the test app from here: https://app.box.com/s/4mqjprxq4khrj3s079w5h2ggzyf690wa

Thanks.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…