Execute a method after an activity is visible to user

前端 未结 5 861
无人及你
无人及你 2021-01-31 18:04

I have an activity contains too many UI controls. I want to execute a method after make the activity visible.

An example i tried:

publi         


        
5条回答
  •  无人共我
    2021-01-31 18:52

    Call MyMethod() in onResume() of Activity

    As per documentation onResume() is called when the activity will start interacting with the user. At this point your activity is at the top of the activity stack, with user input going to it.

    protected void onResume() {
       super.onResume();
       MyMethod();
    }
    

提交回复
热议问题