You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provides information about global focus state, which is managed independently of activity lifecycle. As such, while focus changes will generally have some relation to lifecycle changes (an activity that is stopped will not generally get window focus), you should not rely on any particular order between the callbacks here and those in the other lifecycle methods such as onResume().
As a general rule, however, a foreground activity will have window focus... unless it has displayed other dialogs or popups that take input focus, in which case the activity itself will not have focus when the other windows have it. Likewise, the system may display system-level windows (such as the status bar notification panel or a system alert) which will temporarily take window input focus without pausing the foreground activity.
Starting with Build.VERSION_CODES.Q there can be multiple resumed activities at the same time in multi-window mode, so resumed state does not guarantee window focus even if there are no overlays above.
If the intent is to know when an activity is the topmost active, the one the user interacted with last among all activities but not including non-activity windows like dialogs and popups, then onTopResumedActivityChanged(boolean) should be used. On platform versions prior to Build.VERSION_CODES.Q, onResume() is the best indicator.
The text was updated successfully, but these errors were encountered:
See: https://issuetracker.google.com/issues/232890407
Possible solution is to use
onWindowFocusChanged()
to pause/play audio players but I'm not sure how such a change would affect non-Pixel devices.From: https://developer.android.com/reference/android/app/Activity#onWindowFocusChanged%28boolean%29
Provides information about global focus state, which is managed independently of activity lifecycle. As such, while focus changes will generally have some relation to lifecycle changes (an activity that is stopped will not generally get window focus), you should not rely on any particular order between the callbacks here and those in the other lifecycle methods such as
onResume()
.As a general rule, however, a foreground activity will have window focus... unless it has displayed other dialogs or popups that take input focus, in which case the activity itself will not have focus when the other windows have it. Likewise, the system may display system-level windows (such as the status bar notification panel or a system alert) which will temporarily take window input focus without pausing the foreground activity.
Starting with
Build.VERSION_CODES.Q
there can be multiple resumed activities at the same time in multi-window mode, so resumed state does not guarantee window focus even if there are no overlays above.If the intent is to know when an activity is the topmost active, the one the user interacted with last among all activities but not including non-activity windows like dialogs and popups, then
onTopResumedActivityChanged(boolean)
should be used. On platform versions prior toBuild.VERSION_CODES.Q
,onResume()
is the best indicator.The text was updated successfully, but these errors were encountered: