Feature to listen on window focus events (#25039)

Summary:
Addressed issue: https://github.com/facebook/react-native/issues/24149

On Android, activity's lifecycle events are not triggered when the user pulls down the Status Bar (opening Notification Drawer). In order to know that, you need to override [onWindowFocusChanged method](https://developer.android.com/reference/android/app/Activity.html#onWindowFocusChanged(boolean)).

## Changelog

[Android] [Added] - Adds a new listener for `onWindowFocusChanged`
[JavaScript] [Added] - New event, `focusChanged`, to listen on focus gain/loss
Pull Request resolved: https://github.com/facebook/react-native/pull/25039

Differential Revision: D15644954

Pulled By: cpojer

fbshipit-source-id: 823acffc4287bec4bf56e9f5ffcac65c01cf13d3
This commit is contained in:
Krzysztof Borowy
2019-06-05 16:05:34 -07:00
committed by Facebook Github Bot
parent bf8d918681
commit d45818fe47
7 changed files with 106 additions and 19 deletions
@@ -182,6 +182,12 @@ public class ReactActivityDelegate {
return false;
}
public void onWindowFocusChanged(boolean hasFocus) {
if (getReactNativeHost().hasInstance()) {
getReactNativeHost().getReactInstanceManager().onWindowFocusChange(hasFocus);
}
}
@TargetApi(Build.VERSION_CODES.M)
public void requestPermissions(
String[] permissions,