android window 焦点,When does the *Window focus* change in Android?

In my project, I need to catch the Window focus change. I have logged out the results for all the stages of an activity. When the screen is on, the result is as follows:

02-17 13:50:03.898: DEBUG/InquiryInterface(3829): onCreate screen state : false

02-17 13:50:03.898: DEBUG/InquiryInterface(3829): onStart screen state : false

02-17 13:50:03.898: DEBUG/InquiryInterface(3829): onResume screen state : false

02-17 13:50:08.998: DEBUG/InquiryInterface(3829): onPause screen state : true

02-17 13:50:09.178: DEBUG/InquiryInterface(3829): onWindowFocusChanged : false

02-17 13:50:09.228: DEBUG/InquiryInterface(3829): onStop screen state : false

02-17 13:50:09.228: DEBUG/InquiryInterface(3829): onDestroy screen state : false

onWindowFocusChanged is the method provided by the class Activity. And the value shown in the list is the input value(boolean hasFocus) of the method onWindowFocusChanged.

I have used the following code to get the state of window focus for every state of the method, onCreate, onStart, etc.

@Override

public void onResume() {

super.onResume();

Log.d(TAG, "onCreate screen state : "

+String.valueOf(this.hasWindowFocus()));

}

But in the Android documention, I read : the method 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.

So in this way, I should get "True" for the window focus within onResume, but not in onPause(). Anyone has an idea why this happens?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值