• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Please Help with Activity!

homer759

Lurker
Hello there!
My name is John and i'm having this weird issue.

I've made this application(game) and it has only one Activity.
It's normal it starts calling up onCreate() then onResume() ok, then when i hit the home button he goes to home screen and calls onPause(), and when i try to get back to the application onResume() function is never called again...

Please can someone give me a little help? I'm Trying to make this work about 2 weeks...

[Java] MainActivity - Pastebin.com <--This is the Main Activity

[Java] Screen Manager - Pastebin.com <-- This is the "Canvas Manager"

Thank you for your attention!
 
Unforgiven, could you give some light with the problem? Thanks =D

Unfortunately, no. I have no experience with Android development. I do know one of the devs that is active in this forum (he is a guide as well). He is not online at the moment but I'm sure he'll check in.
 
onPause() is called when it is partially visible (like, there's a prompt pf some sort).

onResume() is called when it returns from what says above.

onStop() is called when the app is hidden.

onStart() is self explained.

Pausing Activity.
Then why is my application calling onPause() when i press the home button and the application is "totally" minimized?

thanks
 
OK, maybe I'm not as dumb as I thought. Pressing the home button should call on pause for any app that is loaded so they have the opportunity to transition into a state where user inputted data or actions are not lost. Think of an email app where the user is composing a message and hits the home button. The email app would want to save the message into the drafts folder so it is not lost. That makes sense.
 
OK, maybe I'm not as dumb as I thought. Pressing the home button should call on pause for any app that is loaded so they have the opportunity to transition into a state where user inputted data or actions are not lost. Think of an email app where the user is composing a message and hits the home button. The email app would want to save the message into the drafts folder so it is not lost. That makes sense.


Exactly, it does save some bundle of data, and when you press it again it just loads in what you left it, calling nothing at all. (I think, not sure).
 
Exactly, it does save some bundle of data, and when you press it again it just loads in what you left it, calling nothing at all. (I think, not sure).
So how will I know when my application opens up again if onResume() is just called after onStop()?
 
Looking at the image below, you will see that when an activity reenters the foreground, after having been completely covered (backgrounded), three calls will be made:
1) onRestart()
2) onStart()
3) onResume()

in that order. I am really baffled as to why you are not seeing an onResume call. Something else you could try would be to fire off another opaque activity and then press the back button to return to your main activity. This should also cause onResume to be called. If it doesn't, you are likely just not reading the log correctly (filters can be tricky sometimes, so something might be happening and you just not seeing it).

Sorry I can't be of much more help.

EDIT: Also, to clarify, onPause is also called when hte activity leaves the foreground entirely, as it must pass the "paused" state before it can enter the "stopped" state. The lifecycle happens in progression and one state cannot be accessed without the activity first passing through all of the preceding states.

activity_lifecycle.png
 
Looking at the image below, you will see that when an activity reenters the foreground, after having been completely covered (backgrounded), three calls will be made:
1) onRestart()
2) onStart()
3) onResume()

in that order. I am really baffled as to why you are not seeing an onResume call. Something else you could try would be to fire off another opaque activity and then press the back button to return to your main activity. This should also cause onResume to be called. If it doesn't, you are likely just not reading the log correctly (filters can be tricky sometimes, so something might be happening and you just not seeing it).

Sorry I can't be of much more help.

EDIT: Also, to clarify, onPause is also called when hte activity leaves the foreground entirely, as it must pass the "paused" state before it can enter the "stopped" state. The lifecycle happens in progression and one state cannot be accessed without the activity first passing through all of the preceding states.

activity_lifecycle.png
The thing is that I have this resume() function wich is called inside onResume(). The function basically get the thread up running again. The program never gets to that call so I guess it doesn't call onResume()... =/

Any thoughts?

thanks
 
Back
Top Bottom