1

Today I'm using Android Intent in the following format to trigger navigation from my application on standalone navigation applications: Action : "android.intent.action.VIEW" URI : "google.navigation:q=48.605086,2.367014/48.607231,2.356997" Component Name of the navigation app : For example Google Maps "com.google.android.apps.maps/com.google.android.maps.MapsActivity"

For example:

Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

from : https://developers.google.com/maps/documentation/urls/android-intents

  1. I want to trigger navigation with multiple way points, Is it possible on TomTom Go Mobile, Google Maps, Waze, Here WeGo and Sygic via Intent ?

  2. Can I trigger navigation on the application above and start driving automatically? Without user interaction ?

I tried to trigger the above intent via ADB and do some tweaking by adding "," , ";", "and". Nothing worked.

bilgo
  • 137
  • 1
  • 9
  • Please refer here documentation : https://developer.here.com/documentation/android-premium/dev_guide/topics/map-service.html Do you have any specific question for HERE API.. please feel free to come up with ? –  Aug 06 '19 at 06:24
  • I want to use HERE We Go application and not to embed the maps in my application. – bilgo Aug 06 '19 at 08:01

1 Answers1

0

In order to open the navigation mode in the HERE WeGo app you can use the following function

private fun navigateToDestination(destination: GeoCoordinate) {
    try {
        val intent = Intent().apply {
            action = "com.here.maps.DIRECTIONS"
            addCategory(Intent.CATEGORY_DEFAULT)
            data = Uri.parse("here.directions://v1.0/mylocation/${destination.latitude},${destination.longitude}")
        }
        intent.resolveActivity(packageManager)?.let {
            startActivity(intent)
        }
    } catch (t: Throwable) {
        Timber.e(t)
    }
}

Sygic:

private fun navigateToDestination(destination: GeoCoordinate) {
    try {
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse("com.sygic.aura://coordinate|${destination.longitude}|${destination.latitude}|drive"))
        intent.resolveActivity(packageManager)?.let {
            startActivity(intent)
        }
    } catch (t: Throwable) {
        Timber.e(t)
    }
}

Waze:

private fun navigateToDestination(destination: GeoCoordinate) {
    try {
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse("waze://?ll=${destination.latitude}, ${destination.longitude}&navigate=yes"))
        intent.resolveActivity(packageManager)?.let {
            startActivity(intent)
        }
    } catch (t: Throwable) {
        Timber.e(t)
    }
}

You can also resolve the installed apps that can be used for navigation and let the user decide which one s/he wants to use:

private fun navigateToDestination(destination: GeoCoordinate) {
    try {
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=${destination.latitude}, ${destination.longitude}"))
        val resolvedPackages = packageManager.queryIntentActivities(intent, PackageManager.MATCH_ALL)
        if (resolvedPackages.isNotEmpty()) {
            val packageNames = resolvedPackages.map { it.activityInfo.packageName }
            val targetIntents = packageNames.map { packageManager.getLaunchIntentForPackage(it) }
            val intentChooser = Intent.createChooser(Intent(), "Choose a navigation app")
            intentChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetIntents.toTypedArray())
            startActivity(intentChooser)
        }
    } catch (t: Throwable) {
        Timber.e(t)
    }
}
no_name
  • 174
  • 1
  • 5
  • Thank you for your answer. So the above will work for multiple destination s? Any clue about TomTom Go? – bilgo Aug 14 '19 at 05:08
  • 1
    According to the documentation of tomtom ( https://developer.tomtom.com/bridge/develop/system-intents ) the URI scheme is the same one used in the last function above eg. google.navigation:q=,. I haven't tried any of them with multiple destinations. – no_name Aug 14 '19 at 06:23
  • 1
    TomTom Go Mobile and TomTom Bridge are different products. The link you provided is leading to a Bridge documentation. – szogoon Aug 19 '19 at 10:47