Skip to content

Commit

Permalink
Merge branch 'fix/deep_linking' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed Dec 7, 2021
2 parents 8d33625 + 6e1197f commit 1f5799f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions audio_service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Guard against NPE when Android service is destroyed quickly.
* Migrate to flutter_lints.
* Queue messages from platform if init() called late.
* Fix deep linking on Android (@vishna/@ryanheise).

## 0.18.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
import java.util.Set;
import java.util.concurrent.Executors;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.NewIntentListener;
import io.flutter.embedding.engine.plugins.FlutterPlugin;

import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.plugin.common.BinaryMessenger;

import io.flutter.embedding.engine.FlutterEngine;
Expand Down Expand Up @@ -71,6 +71,26 @@ public static synchronized FlutterEngine getFlutterEngine(Context context) {
// XXX: The constructor triggers onAttachedToEngine so this variable doesn't help us.
// Maybe need a boolean flag to tell us we're currently loading the main flutter engine.
flutterEngine = new FlutterEngine(context.getApplicationContext());
String initialRoute = null;
if (context instanceof FlutterActivity) {
final FlutterActivity activity = (FlutterActivity)context;
initialRoute = activity.getInitialRoute();
if (initialRoute == null) {
if (activity.shouldHandleDeeplinking()) {
Uri data = activity.getIntent().getData();
if (data != null) {
initialRoute = data.getPath();
if (data.getQuery() != null && !data.getQuery().isEmpty()) {
initialRoute += "?" + data.getQuery();
}
}
}
}
}
if (initialRoute == null) {
initialRoute = "/";
}
flutterEngine.getNavigationChannel().setInitialRoute(initialRoute);
flutterEngine.getDartExecutor().executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault());
FlutterEngineCache.getInstance().put(flutterEngineId, flutterEngine);
}
Expand Down Expand Up @@ -259,7 +279,7 @@ public void onAttachedToActivity(ActivityPluginBinding binding) {
clientInterface.setActivity(binding.getActivity());
clientInterface.setContext(binding.getActivity());
// Verify that the app is configured with the correct FlutterEngine.
FlutterEngine sharedEngine = getFlutterEngine(binding.getActivity().getApplicationContext());
FlutterEngine sharedEngine = getFlutterEngine(binding.getActivity());
clientInterface.setWrongEngineDetected(flutterPluginBinding.getBinaryMessenger() != sharedEngine.getDartExecutor());
mainClientInterface = clientInterface;
registerOnNewIntentListener();
Expand Down

0 comments on commit 1f5799f

Please sign in to comment.