简体   繁体   中英

How to call a method every time an activity is being viewed?

How to call a method every time an activity is being viewed?

For an example, I navigate from activity1 to activity2 . Now I again navigate to activity1 . Each and every time the activity1 is being displayed/navigated to that activity, I need to run the method loadEveryTime() . How can I do this? Please help!

onResume() is called every time the Activity is resumed, so put your method call in there. Make sure to call up to the superclass.

@Override
protected void onResume()
{
  super.onResume();
  loadEveryTime();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM