diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java index 4d5cfcac0dbeb..0990604b9ba1b 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java @@ -399,7 +399,11 @@ private String maybeGetInitialRouteFromIntent(Intent intent) { if (host.shouldHandleDeeplinking()) { Uri data = intent.getData(); if (data != null && !data.getPath().isEmpty()) { - return data.getPath(); + String pathAndQuery = data.getPath(); + if (!data.getQuery().isEmpty()) { + pathAndQuery += "?" + data.getQuery(); + } + return pathAndQuery; } } return null; diff --git a/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java b/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java index e4c02d7492807..509b97791cd9c 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java +++ b/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java @@ -433,7 +433,7 @@ public void itForwardsOnRequestPermissionsResultToFlutterEngine() { public void itSendsInitialRouteFromIntentOnStartIfNoInitialRouteFromActivityAndShouldHandleDeeplinking() { Intent intent = FlutterActivity.createDefaultIntent(RuntimeEnvironment.application); - intent.setData(Uri.parse("http://myApp/custom/route")); + intent.setData(Uri.parse("http://myApp/custom/route?query=test")); ActivityController activityController = Robolectric.buildActivity(FlutterActivity.class, intent); @@ -452,7 +452,8 @@ public void itForwardsOnRequestPermissionsResultToFlutterEngine() { delegate.onStart(); // Verify that the navigation channel was given the initial route message. - verify(mockFlutterEngine.getNavigationChannel(), times(1)).setInitialRoute("/custom/route"); + verify(mockFlutterEngine.getNavigationChannel(), times(1)) + .setInitialRoute("/custom/route?query=test"); } @Test @@ -491,12 +492,13 @@ public void itSendsPushRouteMessageWhenOnNewIntent() { delegate.onAttach(RuntimeEnvironment.application); Intent mockIntent = mock(Intent.class); - when(mockIntent.getData()).thenReturn(Uri.parse("http://myApp/custom/route")); + when(mockIntent.getData()).thenReturn(Uri.parse("http://myApp/custom/route?query=test")); // Emulate the host and call the method that we expect to be forwarded. delegate.onNewIntent(mockIntent); // Verify that the navigation channel was given the push route message. - verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRoute("/custom/route"); + verify(mockFlutterEngine.getNavigationChannel(), times(1)) + .pushRoute("/custom/route?query=test"); } @Test