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

Apps BACK event

sw22

Lurker
Hello,

I have two activities. From the first we go to the second and when the user goes back, I would like to refresh the first activity and change the content of this first activity. Is this possible ?

Thanks,
Swan
 
Sw22, use a static variable as a flag. Then there will be one instance of the variable, and you can have the second activity set the state of the flag. Ex: firstactivity.flagToSet = true;

Then on the first activity, you check the condition on the flagToSet in the onWindowFocusChanged event. This event passes you a hasWindowFocus flag. If it's true, you are coming back, if it's false you are losing focus (ie: going to the second activity). If the flag is true and your flagToSet is true then run your refresh code. You might also want to set your flagToSet =false in the same event if the hasWindowFocus = false. Which means you are headed off to the second activity.

Hope this all makes sense.

After looking at this though, if you refresh every time you come back, just look at the onWindowFocusChanged event. You can refresh every time you get a true passed in.
 
Back
Top Bottom