概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Navigation SDK for Android 可为 Maps SDK for Android 添加导航功能。如果您的 Android 应用由 Google 地图提供支持,并且需要导航功能,则必须依赖于 Navigation SDK for Android。
不过,Maps SDK for Android 中的大多数函数在 Navigation SDK for Android 中的行为方式相同。无论您使用哪个 SDK 依赖项,都可以使用相同的 com.google.android.gms.maps
软件包来访问它们。这意味着,如果您的应用之前依赖于 Maps SDK for Android,您可以将其依赖项更改为 Navigation SDK for Android,而不会影响应用的现有功能,但有以下两个明显的例外情况:
- 抛出异常的 API。
- 在 NavSDK 中不起作用且在调用时没有影响的 API。
下文将介绍这些例外情况。
会抛出异常的 API
如果您的应用启用以下功能,则会抛出异常:
Navigation SDK 中没有功能的 API
以下 API 在 Navigation SDK 中没有任何功能,但如果您的代码调用了这些 API,也不会产生任何影响。它们分为以下几类:
- 用于穿戴式设备活动的 API。
- 如果您想在 Navigation SDK for Android 中使用此功能,请改为启用 TBT Feed。
- 其他 API。
穿戴式设备的 API
GoogleMapOptions.ambientEnabled(boolean enabled) 通常允许您为穿戴式应用停用或启用微光模式。此外,onEnterAmbient 和 onExitAmbient 方法,但调用这些方法时不会产生任何影响。对于穿戴式设备,请改用 TBT Feed。
其他 API
仅供 Mobility Services 客户使用的 API
Navigation SDK 中有多个 API 仅供 Mobility Services 客户使用,这些客户按交易量向 Google 付费。如果您不是移动服务客户,则以下方法为 no-op:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThe Navigation SDK for Android provides navigation features on top of the Maps SDK for Android and is a required dependency for apps needing navigation.\u003c/p\u003e\n"],["\u003cp\u003eMost Maps SDK functionalities remain the same in the Navigation SDK, accessible via the \u003ccode\u003ecom.google.android.gms.maps\u003c/code\u003e package.\u003c/p\u003e\n"],["\u003cp\u003eCertain APIs behave differently in the Navigation SDK, either throwing exceptions (like LiteMode) or having no functionality (like wearable APIs and custom LocationSource).\u003c/p\u003e\n"],["\u003cp\u003eFor wearable apps, the TBT feed should be used instead of ambient mode functionalities.\u003c/p\u003e\n"],["\u003cp\u003eSome APIs are exclusively for Mobility Services customers and function as no-ops for other users.\u003c/p\u003e\n"]]],[],null,["# Overview\n\nThe Navigation SDK for Android adds navigation features to the\nMaps SDK for Android. If your Google Maps-powered Android application\nneeds navigation features, it must depend on the Navigation SDK for Android.\n\nThat said, most functions in the Maps SDK for Android behave the same in\nthe Navigation SDK for Android. You access them using the same\n`com.google.android.gms.maps` package, no matter which SDK dependency you use.\nThis means that, if your app previously depended on the\nMaps SDK for Android, you can change its dependency to the\nNavigation SDK for Android without affecting the existing functionality of your app, with\ntwo notable exceptions:\n\n- APIs that throw an exception.\n- APIs that don't function in the NavSDK and have no impact when called.\n\nThese exceptions are described below.\n\nAPIs that throw an exception\n----------------------------\n\nThe following function throws an exception if your application enables it:\n\n- [LiteMode](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/GoogleMapOptions#liteMode(boolean))\n\nAPIs with no functionality in Navigation SDK\n--------------------------------------------\n\nThe following APIs have no functionality in the Navigation SDK, but also have no\nimpact if your code calls them. They fall into the following categories:\n\n- APIs for wearable activity.\n - Enable [TBT feed](/maps/documentation/navigation/android-sdk/tbt-feed) instead if you want this functionality in the Navigation SDK for Android.\n- Other APIs.\n\n### APIs for wearables\n\n[GoogleMapOptions.ambientEnabled(boolean enabled)](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/GoogleMapOptions#ambientEnabled(boolean)) would\nnormally allow you to disable or enable [ambient mode](/maps/documentation/android-sdk/wear#ambient) for\nwearable apps. Additionally,\n[onEnterAmbient](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/MapView#onEnterAmbient(android.os.Bundle))\nand\n[onExitAmbient](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/MapView#onExitAmbient())\nmethods exist in [MapView](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/MapView) and [MapFragment](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/MapFragment), but have\nno impact when called. For wearables, use the [TBT feed](/maps/documentation/navigation/android-sdk/tbt-feed) instead.\n\n### Other APIs\n\n- [Setting a custom LocationSource](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/GoogleMap#setLocationSource(com.google.android.gms.maps.LocationSource)) does nothing in the NavSDK.\n- All [MapsInitializer](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/MapsInitializer) APIs.\n- [RuntimeRemoteException](/maps/documentation/navigation/android-sdk/reference/com/google/android/gms/maps/model/RuntimeRemoteException).\n\nAPIs that are only intended for use by Mobility Services customers\n------------------------------------------------------------------\n\n\nThere are several APIs in the Navigation SDK that are only intended for use by [Mobility Services](/maps/documentation/transportation-logistics/mobility) customers, who are billed by Google on a per-transaction basis. If you are not a Mobility Services customer, the following methods are no-ops:\n\n- [`NavigationTransactionRecorder.pickup()`](/maps/documentation/navigation/android-sdk/reference/com/google/android/libraries/navigation/NavigationTransactionRecorder#pickup(com.google.android.libraries.navigation.Waypoint,%20java.util.List%3Cjava.lang.String%3E))\n- [`NavigationTransactionRecorder.dropoff()`](/maps/documentation/navigation/android-sdk/reference/com/google/android/libraries/navigation/NavigationTransactionRecorder#dropoff(com.google.android.libraries.navigation.Waypoint,%20java.util.List%3Cjava.lang.String%3E))\n- [`NavigationTransactionRecorder.generatedTransactionId()`](/maps/documentation/navigation/android-sdk/reference/com/google/android/libraries/navigation/NavigationTransactionRecorder#public-static-string-generatetransactionid)\n- [`Navigator.fetchRouteInfo()`](/maps/documentation/navigation/android-sdk/reference/com/google/android/libraries/navigation/Navigator#public-abstract-listenableresultfuturerouteinfo-fetchrouteinfo-waypoint-waypoint,-routingoptions-routingoptions)\n- [`Navigator.setTransactionIds()`](/maps/documentation/navigation/android-sdk/reference/com/google/android/libraries/navigation/Navigator#public-abstract-void-settransactionids-liststring-transactionids)"]]