Commit 474cc58d authored by justin's avatar justin

activity获取

parent 973ccd97
......@@ -3,6 +3,7 @@ package com.idlefish.flutterboost;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import com.idlefish.flutterboost.interfaces.IContainerRecord;
import io.flutter.Log;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
......@@ -42,13 +43,25 @@ class BoostRegistrar implements Registrar, FlutterPlugin, ActivityAware {
}
public Activity activity() {
if(this.activityPluginBinding != null){
IContainerRecord record = FlutterBoost.instance().containerManager().getCurrentTopRecord();
if(record==null){
record = FlutterBoost.instance().containerManager().getLastGenerateRecord();
}
if(record!=null&&record.getContainer().getContextActivity()!=null){
return record.getContainer().getContextActivity();
}
if(this.activityPluginBinding != null&&this.activityPluginBinding.getActivity()!=null){
return this.activityPluginBinding.getActivity();
}
if(FlutterBoost.instance().currentActivity()!=null){
return FlutterBoost.instance().currentActivity();
}
return null;
}
public Context context() {
......
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