Commit ed8b02ae authored by justin's avatar justin Committed by GitHub

Merge pull request #592 from lucky-chen/bugfix/lifcecycle_init

[bugfix] fix crash:'FlutterBoostPlugin not register yet'
parents c0ec5cb2 96b1f2c8
...@@ -26,6 +26,7 @@ public class FlutterBoost { ...@@ -26,6 +26,7 @@ public class FlutterBoost {
private FlutterEngine mEngine; private FlutterEngine mEngine;
private Activity mCurrentActiveActivity; private Activity mCurrentActiveActivity;
private PluginRegistry mRegistry; private PluginRegistry mRegistry;
private boolean mEnterActivityCreate =false;
static FlutterBoost sInstance = null; static FlutterBoost sInstance = null;
private long FlutterPostFrameCallTime = 0; private long FlutterPostFrameCallTime = 0;
...@@ -56,6 +57,10 @@ public class FlutterBoost { ...@@ -56,6 +57,10 @@ public class FlutterBoost {
@Override @Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) { public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
//fix crash:'FlutterBoostPlugin not register yet'
//case: initFlutter after Activity.OnCreate method,and then called start/stop crash
// In SplashActivity ,showDialog(in OnCreate method) to check permission, if authorized, then init sdk and jump homePage)
mEnterActivityCreate = true;
mCurrentActiveActivity = activity; mCurrentActiveActivity = activity;
if (mPlatform.whenEngineStart() == ConfigBuilder.ANY_ACTIVITY_CREATED) { if (mPlatform.whenEngineStart() == ConfigBuilder.ANY_ACTIVITY_CREATED) {
doInitialFlutter(); doInitialFlutter();
...@@ -70,6 +75,9 @@ public class FlutterBoost { ...@@ -70,6 +75,9 @@ public class FlutterBoost {
@Override @Override
public void onActivityStarted(Activity activity) { public void onActivityStarted(Activity activity) {
if (!mEnterActivityCreate){
return;
}
if (mCurrentActiveActivity == null) { if (mCurrentActiveActivity == null) {
Debuger.log("Application entry foreground"); Debuger.log("Application entry foreground");
...@@ -84,16 +92,24 @@ public class FlutterBoost { ...@@ -84,16 +92,24 @@ public class FlutterBoost {
@Override @Override
public void onActivityResumed(Activity activity) { public void onActivityResumed(Activity activity) {
if (!mEnterActivityCreate){
return;
}
mCurrentActiveActivity = activity; mCurrentActiveActivity = activity;
} }
@Override @Override
public void onActivityPaused(Activity activity) { public void onActivityPaused(Activity activity) {
if (!mEnterActivityCreate){
return;
}
} }
@Override @Override
public void onActivityStopped(Activity activity) { public void onActivityStopped(Activity activity) {
if (!mEnterActivityCreate){
return;
}
if (mCurrentActiveActivity == activity) { if (mCurrentActiveActivity == activity) {
Debuger.log("Application entry background"); Debuger.log("Application entry background");
...@@ -108,11 +124,16 @@ public class FlutterBoost { ...@@ -108,11 +124,16 @@ public class FlutterBoost {
@Override @Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) { public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
if (!mEnterActivityCreate){
return;
}
} }
@Override @Override
public void onActivityDestroyed(Activity activity) { public void onActivityDestroyed(Activity activity) {
if (!mEnterActivityCreate){
return;
}
if (mCurrentActiveActivity == activity) { if (mCurrentActiveActivity == activity) {
Debuger.log("Application entry background"); Debuger.log("Application entry background");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment