今天,我正在以以下格式使用Android意图来触发我的应用程序在独立导航应用程序上的导航:动作:" android.intent.action.view"URI:" Google.Navigation:Q = 48.605086,2.367014/48.607231,2.35697"导航应用程序的组件名称:例如Google Maps" com.google.android.apps.mapss.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
我想用多种方式点触发导航,在Tomtom Go Mobile,Google Maps,Waze,Wego和Sygic上是否有可能通过意图?
我可以在上面的应用程序上触发导航并开始自动驾驶吗?没有用户互动?
我试图通过ADB触发上述意图,并通过添加",",";"one_answers"进行一些调整。什么都没有。
为了在此处的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)
}
}
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)
}
}
您还可以解析可用于导航的已安装应用程序,并让用户决定要使用哪个应用程序:
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)
}
}