Android Question Strange behaviour when using Activity.Finish

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I'm experiencing some strange behaviour when using Activity.Finish

I have an app that has a Main activity and it calls another activity called Students using a button. I compile and install the app. When I run the app from the Open button of the installer I tap the Students button to display the Students activity. When I tap a button the has Activity.Finish the app closes and any coding in the Activity_Resume sub procedure is not executed. The same thing happens when I tap the phone's Back button.

I placed toast messages in Activity_Resume and in Activity_Pause and Activity_Resume is displayed when running the app and Activity_Pause is displayed when calling the Students activity so at least I know those parts are working. When the toast messages are in those sub routines using Activity.Finish does work once in a while. It's intermittent.

I checked the phone's storage and there was 6.52GB left. The external SD card has 537MB available.

What is the proper way to start the Main activity then call the Students activity and return back to the Main activity without exiting the app?

Thanks.
 
Last edited:

JonPM

Well-Known Member
Licensed User
Longtime User
Can you post a small project that does what you are saying. Your description is a bit hard to follow.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Jon,

You can download the small project from: https://app.box.com/s/4mqjprxq4khrj3s079w5h2ggzyf690wa

When you install it, don't run it from the installer. The app is called Emad Test. Run it from the screen that shows all the apps.

When the main screen is displayed, tap the Settings button. When the settings screen is shown tap the Exit button and the app will exit without going back to the main screen. If this doesn't happen on your phone then B4A may be having a problem with mine. Mine is an Umi Zero running KitKat.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
It works OK on my Sony xperia z1, Android 5.1.1,

Did you run it from the apps screen and not the installer?

Looks like maybe it's my phone. I will see if I can turn off some of the other running apps and see if that makes a difference.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
I tested it in:
- rapid Debug mode launched from B4ABrige
- Release mode launched from B4ABrige
- Release mode launched from the the apps screen on the device.

I can live with that part not working at least on my phone, but maybe I can assume it will work on most other devices like it works on yours. This does not happen to other apps I made in the past. It only happens to all new apps I make with the current version of B4A.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
I'm going to copy a working app and strip it down and start to add coding from the new app to see if I can figure out what is causing the problem.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
I found out what was causing the problem. It's with the icon button library and I was using the up and down button handlers. When I changed to using just the click handler everything worked fine.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…