可以将你要执行的方法checkPendingNotification在onUserInteraction()和onWindowFocusChanged()中调用
@Override
public void onUserInteraction() {
checkPendingNotification();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
if (hasFocus) {
checkPendingNotification();
}
}