10
10
import android .net .Uri ;
11
11
import android .os .Bundle ;
12
12
import android .os .Build ;
13
+ import android .content .pm .PackageManager ;
13
14
14
15
15
16
import androidx .annotation .NonNull ;
29
30
import io .flutter .plugin .common .MethodChannel ;
30
31
import io .flutter .plugin .common .MethodChannel .MethodCallHandler ;
31
32
import io .flutter .plugin .common .MethodChannel .Result ;
32
- import io .flutter .plugin .common .PluginRegistry .Registrar ;
33
33
34
34
import com .google .android .gms .common .GoogleApiAvailability ;
35
35
import com .google .android .gms .common .ConnectionResult ;
@@ -55,6 +55,8 @@ public class FirebaseDartFlutterPlugin implements FlutterPlugin, MethodCallHandl
55
55
56
56
private FlutterPluginBinding binding ;
57
57
58
+ private Context applicationContext ;
59
+
58
60
static final String ACTION_AUTH_RECEIVED = "be.appsup.firebase_dart_flutter.ACTION_AUTH_RECEIVED" ;
59
61
static final String ACTION_RECAPTCHA_RECEIVED = "be.appsup.firebase_dart_flutter.ACTION_RECAPTCHA_RECEIVED" ;
60
62
@@ -63,8 +65,17 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
63
65
channel = new MethodChannel (flutterPluginBinding .getBinaryMessenger (), "firebase_dart_flutter" );
64
66
channel .setMethodCallHandler (this );
65
67
binding = flutterPluginBinding ;
68
+ applicationContext = binding .getApplicationContext ();
69
+ }
66
70
71
+ private void bringAppToFront () {
72
+ Intent intent = applicationContext .getPackageManager ()
73
+ .getLaunchIntentForPackage (applicationContext .getPackageName ());
67
74
75
+ if (intent != null ) {
76
+ intent .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK | Intent .FLAG_ACTIVITY_REORDER_TO_FRONT );
77
+ applicationContext .startActivity (intent );
78
+ }
68
79
}
69
80
70
81
@ Override
@@ -103,6 +114,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull final Result result)
103
114
public void onReceive (Context context , Intent intent ) {
104
115
result .success (bundleToMap (intent .getExtras ()));
105
116
binding .getApplicationContext ().unregisterReceiver (this );
117
+ bringAppToFront ();
106
118
}
107
119
};
108
120
IntentFilter filter = new IntentFilter (ACTION_AUTH_RECEIVED );
@@ -114,6 +126,7 @@ public void onReceive(Context context, Intent intent) {
114
126
public void onReceive (Context context , Intent intent ) {
115
127
result .success (bundleToMap (intent .getExtras ()));
116
128
binding .getApplicationContext ().unregisterReceiver (this );
129
+ bringAppToFront ();
117
130
}
118
131
};
119
132
filter = new IntentFilter (ACTION_RECAPTCHA_RECEIVED );
0 commit comments