Android Question Back Button, Home Button curious phenomena

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All

This is a question out of curiosity only. I have a small games App, "Atoms". Most people will have seen one of the many implementations of this game by many developers. Basically atoms are added to squares on a grid of squares until a square reaches critical mass and explodes etc.

In my App the player can exit the game with the Back button, restart the game and continue. This works as normal, no surprises.
If the player exits the game using the Home button and restarts the game it mostly works OK but "Ghost" images of the atoms before exploding remain?

BackButton.jpg HomeButton.jpg

I think the App itself is incidental to the problem but here is a link to the Sourcecode if this can help with the answer. The simple answer of course is "always use the Back button", but it is curious.

Any thoughts?

Regards Roger
 
Last edited:

sorex

Expert
Licensed User
Longtime User
are you sure you're not placing new dots somewhere at activity resume?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I think that an app should allow to suspend using the Home button and the Back button should be disabled, but this is off topic, as usual :)

Means this that the lifetime of the app is affected by the choice between the two keys?
I think not; when you reactivate your app, the Resume is performed in both cases.

[Note that your text has only one link]
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
In my App the player can exit the game with the Back button, restart the game and continue. This works as normal, no surprises.
If the player exits the game using the Home button and restarts the game it mostly works OK but "Ghost" images of the atoms before exploding remain?

Just a quick test and I can not see difference between Back and Home.

I see two things I don't like :):

1) you can not close the app definitively
2) too many warnings ("Variable declar..." and "Return type...")
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi LucaMs,

A bit more detail on the ghost atoms. The Home button problem occurs on squares that have atoms when the the App is exited. When these squares are cleared by an explosion a grey version of the atoms at the time of exit appears. NOTE: The image is that shown at time of exit not the time of the explosion.

Warnings: Yes, far too many. I noted this in another App I was updating. I think Erel has improved the monitoring of such things in the latest version of B4A. With the other App it made me take a more disciplined approach and I cleared those warnings. If I update Atoms I will do the same.

Can you explain what you mean by "you can not close the app definitively"? I have read posts discussing Back button v's App Exit button, the consensus seemed to be use the Back button.

Roger
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Hi LucaMs,

A bit more detail on the ghost atoms. The Home button problem occurs on squares that have atoms when the the App is exited. When these squares are cleared by an explosion a grey version of the atoms at the time of exit appears. NOTE: The image is that shown at time of exit not the time of the explosion.

Warnings: Yes, far too many. I noted this in another App I was updating. I think Erel has improved the monitoring of such things in the latest version of B4A. With the other App it made me take a more disciplined approach and I cleared those warnings. If I update Atoms I will do the same.

Can you explain what you mean by "you can not close the app definitively"? I have read posts discussing Back button v's App Exit button, the consensus seemed to be use the Back button.

Roger


I thought I saw the "ghosts" after an explosion and not see them after another explosion. However, I have to try again.

The warnings are useful; the advice is to correct the problem, so you have only real error messages in the list.

To end the app you should definitely search on site.
I prefer to disable the Back button (if the user wants to suspend the game he can use Home or the key for the recent apps) and I put a button to close the app (with ExitApplication and all the activities already closed).
 
Upvote 0

hibrid0

Active Member
Licensed User
Longtime User
I have a similar issue, "ghost" images from the same activity, if I loaded again.
I solved it with Activity.removeAllViews
 
Upvote 0

hibrid0

Active Member
Licensed User
Longtime User
Hi Roger, I attach the project fixed. I dont do a lot. And maybe my solution is too basic, but done the work ;-).
I'm so new with Basic4Android, I have 35 days with it.
 

Attachments

  • atoms.zip
    348.3 KB · Views: 250
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
hibrid,

An interesting solution. Don't worry about being new at this, I have just passed a year and still very much a newbie.

Still has me puzzled why to resume after a Home button exit is different from a Back button exit. Who knows.

Thanks for your help.

Regards Roger
 
Upvote 0

hibrid0

Active Member
Licensed User
Longtime User
hibrid,

An interesting solution. Don't worry about being new at this, I have just passed a year and still very much a newbie.

Still has me puzzled why to resume after a Home button exit is different from a Back button exit. Who knows.

Thanks for your help.

Regards Roger
Hi I think is about life cycle, if you press back, the activity and all views is end and if you press home the views are not ended, then if you start again the app, in case of resume from back button start in Activity Start, and if you start from home button, start in resume and the old views are there, the images are maybe a little of transparency, then you see the "ghosts".
In my case was a document viewer, if I load in first time I see the document and the pages separator, and if load again, I don't see the pages separator, I see something like an error or erratic info, but I pay more attention, I see was the same document but the old views are actively in background of my current views, I go for the easy way, remove all views.

Or maybe I dont know what I talk, because I'm so newbe, and was just a good luck of newbe.
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
I prefer to disable the Back button (if the user wants to suspend the game he can use Home or the key for the recent apps) and I put a button to close the app (with ExitApplication and all the activities already closed).
But why? This behaviour is completely against the android standards. A app is normally not closed exit by user, only by system.
 
Upvote 0
Top