Android Question Back Button, Home Button curious phenomena

Discussion in 'Android Questions' started by Roger Daley, Jul 1, 2015.

  1. Roger Daley

    Roger Daley Well-Known Member Licensed 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: Jul 1, 2015
  2. sorex

    sorex Expert Licensed User

    are you sure you're not placing new dots somewhere at activity resume?
     
  3. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Hi sorex,

    I don't think it can be activity resume as this would also happen when I exit using the back button.

    Roger
     
  4. LucaMs

    LucaMs Expert Licensed 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]
     
  5. Roger Daley

    Roger Daley Well-Known Member Licensed User

    LucaMs,

    Thanks for the feedback especially the one link. It seems that two links in a post doesn't work, when I change one the other also changes.
    Playstore link now in this post.


    Roger
     
  6. LucaMs

    LucaMs Expert Licensed User

    it works but with little problems. Insert few empty lines and only then add text+link.
     
    Roger Daley likes this.
  7. LucaMs

    LucaMs Expert Licensed User

    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...")
     
  8. Roger Daley

    Roger Daley Well-Known Member Licensed 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
     
  9. sorex

    sorex Expert Licensed User

    why not clear and redraw the grid at resume?
     
    Roger Daley likes this.
  10. LucaMs

    LucaMs Expert Licensed User


    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).
     
    Roger Daley likes this.
  11. hibrid0

    hibrid0 Active Member Licensed User

    I have a similar issue, "ghost" images from the same activity, if I loaded again.
    I solved it with Activity.removeAllViews
     
  12. Roger Daley

    Roger Daley Well-Known Member Licensed User

    hibrid0,

    Did you add this to Activity_Resume and recreate all views in Activity_Resume?

    Roger
     
  13. hibrid0

    hibrid0 Active Member Licensed User

    Hi Roger check if was solved.
     

    Attached Files:

  14. Roger Daley

    Roger Daley Well-Known Member Licensed User

    hibrid0,

    Yes, whatever you did stopped the "Ghosts". I would be interested in how you did it and does it explain why the problem occurs with the Home button and not the Back button.


    Regards Rogers
     
  15. hibrid0

    hibrid0 Active Member Licensed 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.
     

    Attached Files:

    Roger Daley and DonManfred like this.
  16. Roger Daley

    Roger Daley Well-Known Member Licensed 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
     
  17. hibrid0

    hibrid0 Active Member Licensed User

    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.
     
    Roger Daley likes this.
  18. Roger Daley

    Roger Daley Well-Known Member Licensed User

    I think you are absolutely correct, what you say covers everything. The images for the Atoms are slightly transparent.

    Thanks for the help.

    Roger
     
  19. MaFu

    MaFu Well-Known Member Licensed User

    But why? This behaviour is completely against the android standards. A app is normally not closed exit by user, only by system.
     
  20. Roger Daley

    Roger Daley Well-Known Member Licensed User

    OK, back to square one.

    I admit my ignorance which is why I originally asked the question.

    Roger
     
    Last edited: Jul 2, 2015
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice