總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 版 Navigation SDK 會在 Android 版 Maps SDK 中加入導航功能。如果以 Google 地圖為基礎的 Android 應用程式需要導航功能,就必須依附於 Android 版 Navigation SDK。
不過,Navigation SDK for Android 中的大部分函式,行為都與 Maps SDK for Android 相同。無論使用哪個 SDK 依附元件,您都可以透過相同的 com.google.android.gms.maps
套件存取這些 API。也就是說,如果您的應用程式先前依附於 Maps SDK for Android,您可以將其依附元件變更為 Navigation SDK for Android,而不會影響應用程式的現有功能,但有兩個明顯例外:
- 會擲回例外狀況的 API。
- 這些 API 無法在 NavSDK 中運作,呼叫時也不會產生任何影響。
以下說明這些例外狀況。
會擲回例外狀況的 API
如果應用程式啟用下列函式,就會擲回例外狀況:
Navigation SDK 中沒有功能的 API
下列 API 在 Navigation SDK 中沒有任何功能,但如果您的程式碼呼叫這些 API,也不會造成任何影響。這些問題可分為以下幾類:
- 穿戴式裝置活動的 API。
- 如要在 Navigation SDK for Android 中使用這項功能,請改為啟用 TBT 資訊動態消息。
- 其他 API。
穿戴式裝置專用 API
GoogleMapOptions.ambientEnabled(boolean enabled) 通常可讓您為穿戴式應用程式停用或啟用微光模式。此外,MapView 和 MapFragment 中也有 onEnterAmbient 和 onExitAmbient 方法,但呼叫時不會產生任何影響。如果是穿戴式裝置,請改用 TBT 動態饋給。
其他 API
僅供 Mobility Services 客戶使用的 API
Navigation SDK 中有幾項 API 僅供 Mobility Services 客戶使用,Google 會按交易次數向這類客戶收費。如果您不是 Mobility Services 客戶,下列方法不會執行任何作業:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間: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)"]]