Android App strange behaviour when comeing back from sleep

since i am stuck on this problem and don't know where my mistake is I need to ask you guys. When I first launch my app everything works fine, but when i press the "back" button on my phone to get back to main screen and start the app again (which is not a real new startup because app goes to sleep) it has a really strange behaviour. I am using opengles to draw a texture onto the screen and when I make a touch the texture changes. The touch sets a boolean to true that indicates to draw the other texture. But somehow it is always false when I test its value even when it just got written to true from touch event. I was wondering because that only happens when I pressed the "back" button on the phone. When I am returning to main screen with the home button and then moving back to the app this thing doesnt occur and everything works. First I thought it is something with the threads 2 different threads(activity rendering thread and surfaceview thread for touch events) but even when synchronizing all get/set methods it still doesnt work. I am starting to think that the touch thread thing is still operating on old objects and changes values there while the references in the rendering thread get newly instanciated so the boolean is set by touch but the rendering thread only takes the default value because they got different objects what is obviously somehow not possible. Well I am at end of my knowledge so please enlighten me Edit: Well I found the mistake... When the device came back from sleep it created another object(the textured square) and then the touch event occured on the old one which was not delted and the new one got drawn. Also it would be nice if somebody could tell me which exact methods get called when it comes back from sleep? Is it only onResume or are there more? And what about references, do they get also deleted because there shouldnt be created another object, I even test for == null and then create a new one but somehow this seems to be true when it comes back
Can you post the gl renderer code and also the part where the boolean flag is set from the touch events. It might help us more in solving the issue

以上就是Android App strange behaviour when comeing back from sleep的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准