Re-land "do not pause rendering when android view loses focus" (#5004)

* do not pause rendering when android view loses focus
This commit is contained in:
Jonah Williams 2018-04-13 17:08:00 -07:00 committed by GitHub
parent 91dee5981f
commit 0b7d6be976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 5 deletions

View File

@ -47,10 +47,14 @@ enum AppLifecycleState {
/// in the foreground inactive state. Apps transition to this state when in
/// a phone call, responding to a TouchID request, when entering the app
/// switcher or the control center, or when the UIViewController hosting the
/// Flutter app is transitioning. Apps in this state should assume that they
/// may be [paused] at any time.
/// Flutter app is transitioning.
///
/// On Android, this state is currently unused.
/// On Android, this corresponds to an app or the Flutter host view running
/// in the foreground inactive state. Apps transition to this state when
/// another activity is focused, such as a split-screen app, a phone call,
/// a picture-in-picture app, a system dialog, or another window.
///
/// Apps in this state should assume that they may be [paused] at any time.
inactive,
/// The application is not currently visible to the user, not responding to

View File

@ -99,6 +99,12 @@ public class FlutterActivity extends Activity implements FlutterView.Provider, P
super.onBackPressed();
}
}
@Override
protected void onStop() {
eventDelegate.onStop();
super.onStop();
}
@Override
protected void onPause() {

View File

@ -218,6 +218,11 @@ public final class FlutterActivityDelegate
}
}
@Override
public void onStop() {
flutterView.onStop();
}
@Override
public void onPostResume() {
if (flutterView != null) {

View File

@ -54,6 +54,11 @@ public interface FlutterActivityEvents
*/
void onDestroy();
/**
* @see android.app.Activity#onStop()
*/
void onStop();
/**
* Invoked when the activity has detected the user's press of the back key.
*

View File

@ -98,6 +98,12 @@ public class FlutterFragmentActivity
}
}
@Override
protected void onStop() {
eventDelegate.onStop();
super.onStop();
}
@Override
protected void onPause() {
super.onPause();

View File

@ -267,7 +267,7 @@ public class FlutterView extends SurfaceView
}
public void onPause() {
mFlutterLifecycleChannel.send("AppLifecycleState.paused");
mFlutterLifecycleChannel.send("AppLifecycleState.inactive");
}
public void onPostResume() {
@ -278,7 +278,7 @@ public class FlutterView extends SurfaceView
}
public void onStop() {
mFlutterLifecycleChannel.send("AppLifecycleState.suspending");
mFlutterLifecycleChannel.send("AppLifecycleState.paused");
}
public void onMemoryPressure() {