1

今天,我使用以下格式的 Android Intent 在独立导航应用程序上触发我的应用程序导航:操作:“android.intent.action.VIEW”URI:“google.navigation:q=48.605086,2.367014/48.607231,2.356997”导航应用的组件名称:例如谷歌地图“com.google.android.apps.maps/com.google.android.maps.MapsActivity”

例如:

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

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

  1. 我想用多个航点触发导航,是否可以通过 Intent 在 TomTom Go Mobile、Google Maps、Waze、Here WeGo 和 Sygic 上使用?

  2. 我可以在上面的应用程序上触发导航并自动开始驾驶吗?没有用户交互?

我尝试通过 ADB 触发上述意图,并通过添加“,”,“;”,“和”进行一些调整。没有任何效果。

4

1 回答 1

0

为了在 HERE WeGo 应用程序中打开导航模式,您可以使用以下功能

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)
    }
}

锡吉克:

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)
    }
}

位智:

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)
    }
}

您还可以解析已安装的可用于导航的应用程序,并让用户决定要使用哪个应用程序:

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)
    }
}
于 2019-08-12T19:15:20.700 回答