How to use onWindowFocusChanged() method?

前端 未结 3 360
温柔的废话
温柔的废话 2020-12-14 07:22

I am confused in how to trigger an event when the activity is changed. One thing that I know is using onWindowFocusChanged() method but I don\'t know how to use

3条回答
  •  无人及你
    2020-12-14 07:54

    Called when the current Window of the activity gains or loses focus. This is the best indicator of whether this activity is visible to the user. The default implementation clears the key tracking state, so should always be called.

    @Override
    public void onWindowFocusChanged(boolean hasFocas) {
        super.onWindowFocusChanged(hasFocas);
        //your code here
    }
    

    hasFocus boolean: Whether the window of this activity has focus.

提交回复
热议问题