Skip to content

NavInfoEvent not triggered in android when application is in background/minimized #169

@DhirajMakane

Description

@DhirajMakane

Hi,
Navinfo event is not triggered when application is in background.

Environment details

google_navigation_flutter: ^0.3.0
Observed for android (Note iOS is working)
Flutter - 3.22.3
Location Permissions are enabled
Permissions added

Steps to reproduce

Set destination and origin.
Open Google Maps for turn-by-turn navigation
Initial self-location and the route are displayed on the map
Be in the app for a few minutes. The nav info events are received.
Now minimize the app -> The nav info events are not triggered

AndroidManifest

Flutter Code Snippet

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_TYPE_LOCATION" />


Future<void> _startNavigation() async {
   // popup for the terms and condition
   if (!await GoogleMapsNavigator.areTermsAccepted()) {
     await GoogleMapsNavigator.showTermsAndConditionsDialog(
       'Sample APP',
       'Sample APP',
     );
   }

   await GoogleMapsNavigator.initializeNavigationSession();
   await _setupListeners();

   /// Simulate location.
   await GoogleMapsNavigator.simulator.setUserLocation(widget.sourceLocation);

// add way points
   var wayPoints = <NavigationWaypoint>[
     NavigationWaypoint.withLatLngTarget(
       title: "destination title",
       target: widget.destinationLocation,
     ),
   ];
   final Destinations msg = Destinations(
       waypoints: wayPoints,
       displayOptions: NavigationDisplayOptions(showDestinationMarkers: true),
       routingOptions:
           RoutingOptions(travelMode: NavigationTravelMode.twoWheeler));

   final NavigationRouteStatus status =
       await GoogleMapsNavigator.setDestinations(msg);

   if (status == NavigationRouteStatus.statusOk) {
     await GoogleMapsNavigator.startGuidance();

     await _navigationViewController
         .followMyLocation(CameraPerspective.tilted);
   }
 }

 // set the nav info listener
 Future<void> _setupListeners() async {
   _navInfoSubscription = GoogleMapsNavigator.setNavInfoListener(
     _onNavInfoEvent,
     numNextStepsToPreview: 10,
   );
 }

 // event listened to update the logs
 void _onNavInfoEvent(
   NavInfoEvent event,
 ) {
   print("nav info event received");
 }

Thanks!

Metadata

Metadata

Labels

status: investigatingThe issue is under investigation, which is determined to be non-trivial.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions