skip to Main Content

I have an application that works according to the map, but I want another software to do the routing
I went so far that it opens the map of that navigation application, but on my own application, but I want it to open inside the same application, not on my own application.
How do I do this?

_launchURL() async {
    _getCurrentLocation().then((value) async {
      final Uri url =
          Uri.parse('https://nshn.ir?origin=${value.latitude},${value.longitude}&destination=$lat,$lon&vehicle=d');
      if (!await launchUrl(url)) {
        throw Exception('Could not launch $url');
      }
    });
  }

  Future<Position> _getCurrentLocation() async {
    bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
    if (!serviceEnabled) {
      return Future.error("اجازه مکان داده نشده است");
    }

    LocationPermission permission = await Geolocator.checkPermission();
    if (permission == LocationPermission.denied) {
      permission = await Geolocator.requestPermission();
      if (permission == LocationPermission.denied) {
        return Future.error("اجازه مکان داده نمیشود");
      }
    }

    if (permission == LocationPermission.deniedForever) {
      return Future.error("اجازه مکان داه نمیشود کلا");
    }

    return await Geolocator.getCurrentPosition();
  }
}

2

Answers


  1. Try This :

    In your androidManifest file, inside activity change android:launchMode to single task

            <activity
                android:name=".MainActivity"
                android:exported="true"
                android:launchMode="singleTask"
    
    
    Login or Signup to reply.
  2. Please refer this section

    You can use LaunchMode.externalApplication for mode parameter

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search