2012-08-10 60 views

回答

1

onUserLeaveHint()

调用作为活动周期的一部分,当活动即将 去到后台,成为用户选择的结果。例如,当 用户按Home键时,onUserLeaveHint()将被调用,但 当来电呼叫导致呼叫中的Activity被自动带到前台 时,onUserLeaveHint()将不会被呼叫 活动被中断。在被调用的情况下, 在活动的onPause()回调之前调用此方法。

使布尔变量真内onUserLeaveHint()为:

@Override 
    public void onUserLeaveHint() { 
       super.onUserLeaveHint(); 
       //make Boolean true here because this method first 
       //called when user press home key 
      } 
1

你需要重写附加于窗的方法。 请检查以下代码。

@Override 
public void onAttachedToWindow() { 
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); 
super.onAttachedToWindow(); 
//set your boolean value here 
}