Handle enter background&foreground.