Entry point to the Navigation API. Use the static methods on this class to obtain a reference to
the Navigator
.
Nested Class Summary
@interface | NavigationApi.ErrorCode | An ErrorCode is a status code returned by getNavigator(Activity, NavigatorListener)
and getNavigator(Application, NavigatorListener) when a Navigator could not be
successfully obtained. |
|
interface | NavigationApi.NavigatorListener | Register a NavigatorListener with getNavigator(Activity, NavigatorListener) to be
notified about the status of said Navigator . |
|
interface | NavigationApi.OnTermsResponseListener | Register an OnTermsResponseListener with showTermsAndConditionsDialog(Activity, String, OnTermsResponseListener) to be notified when the user accepts or declines the terms and
conditions. |
Public Method Summary
static boolean |
areTermsAccepted(Application application)
Returns
true if the user has previously accepted Google's Navigation terms and
conditions. |
static void |
cleanup()
Cleans up internal state of the NavSDK components.
|
synchronized static ForegroundServiceManager |
getForegroundServiceManager(Application application)
Obtains the singleton
ForegroundServiceManager instance. |
static String |
getNavSDKVersion()
Returns the current NavSDK version.
|
static void |
getNavigator(Application application, NavigationApi.NavigatorListener callback)
Obtains the
Navigator instance. |
static void |
getNavigator(Activity activity, NavigationApi.NavigatorListener callback, TermsAndConditionsCheckOption termsCheck)
Obtains the
Navigator instance. |
static void |
getNavigator(Activity activity, NavigationApi.NavigatorListener callback)
Equivalent to
getNavigator(activity, callback, {@link
TermsAndConditionsCheckOption#ENABLED} . |
static void |
getNavigatorNoToS(Application application, NavigationApi.NavigatorListener callback)
Obtains the
Navigator instance. |
static RoadSnappedLocationProvider |
getRoadSnappedLocationProvider(Application application)
Obtains an instance of the
RoadSnappedLocationProvider , which can be used to subscribe
to road-snapped user locations. |
static NavigationTransactionRecorder |
getTransactionRecorder(Application application)
Obtains an instance of the
NavigationTransactionRecorder , which can be used to record
transactions related to navigation. |
synchronized static void |
initForegroundServiceManager(Application application, Integer notificationId, String defaultMessage, NotificationContentProvider provider)
Initializes the
ForegroundServiceManager instance with provided arguments. |
static void |
resetTermsAccepted(Application application)
Reset the terms and conditions - for testing.
|
static void |
showTermsAndConditionsDialog(Activity activity, String companyName, String title, NavigationApi.OnTermsResponseListener listener)
Displays a dialog that directs the user to accept Google's Navigation terms and conditions,
using the default look and feel.
|
static void |
showTermsAndConditionsDialog(Activity activity, String companyName, String title, TermsAndConditionsUIParams uiParams, NavigationApi.OnTermsResponseListener listener, TermsAndConditionsCheckOption termsAndConditionsCheckOption)
Displays a dialog that directs the user to accept Google's Navigation terms and conditions.
|
static void |
showTermsAndConditionsDialog(Activity activity, String companyName, NavigationApi.OnTermsResponseListener listener)
Displays a dialog that directs the user to accept Google's Navigation terms and conditions,
using the default title and the default look and feel.
|
Inherited Method Summary
Public Methods
public static boolean areTermsAccepted (Application application)
Returns true
if the user has previously accepted Google's Navigation terms and
conditions.
You can use this to check whether you should display the terms screen earlier in the application, rather than when the user is about to navigate somewhere. For example, it might be appropriate to check this value when your app is showing other terms and conditions, so that the user can accept all required terms and conditions for the app in one task.
Parameters
application | the current application |
---|
Returns
true
if the terms have been accepted by the user, andfalse
otherwise
public static void cleanup ()
Cleans up internal state of the NavSDK components. If a current navigator exists, guidance is stopped and disabled. No future calls for guidance can be made from this Navigator. Call this method to recover memory when your app no longer requires the Navigator and your app has destroyed all references to the Navigator. If your app requires a Navigator after this call, use getNavigator() to create a new one. Note: Creating a new Navigator takes time; consider how a delay would impact your app's performance versus the benefits of recovered memory.
public static synchronized ForegroundServiceManager getForegroundServiceManager (Application application)
Obtains the singleton ForegroundServiceManager
instance. If initForegroundServiceManager(Application, Integer, String, NotificationContentProvider)
is not called before getForegroundServiceManager(Application)
, a
default notification ID, message and notification provider will be used.
Parameters
application | the current Application
|
---|
public static String getNavSDKVersion ()
Returns the current NavSDK version.
public static void getNavigator (Application application, NavigationApi.NavigatorListener callback)
Obtains the Navigator
instance.
If the user has not yet agreed to the terms and conditions, the callback will immediately be
fired with the error code TERMS_NOT_ACCEPTED
.
Note that Navigator is a singleton; if you call this method multiple times, each call will return the same Navigator.
Parameters
application | the current Application |
---|---|
callback | a callback which will be fired when the Navigator is ready, or an error
occurs
|
public static void getNavigator (Activity activity, NavigationApi.NavigatorListener callback, TermsAndConditionsCheckOption termsCheck)
Obtains the Navigator
instance.
If the user has not yet agreed to the terms and conditions, this call will show a dialog exhorting the user to abide by local regulations.
If termsCheck
is ENABLED
, the dialog will also
contain a link to the Terms and Conditions for the Navigation SDK. The callback
will be
called with a TERMS_NOT_ACCEPTED
error if the user fails to accept these
terms.
Note that Navigator is a singleton; if you call this method multiple times, each call will return the same Navigator.
public static void getNavigator (Activity activity, NavigationApi.NavigatorListener callback)
Equivalent to getNavigator(activity, callback, {@link
TermsAndConditionsCheckOption#ENABLED}
.
Parameters
activity | |
---|---|
callback |
public static void getNavigatorNoToS (Application application, NavigationApi.NavigatorListener callback)
Obtains the Navigator
instance.
Bypasses the terms and conditions.
Note that Navigator is a singleton; if you call this method multiple times, each call will return the same Navigator.
Parameters
application | the current Application . |
---|---|
callback | a callback which will be fired when the Navigator is ready, or an error
occurs.
|
public static RoadSnappedLocationProvider getRoadSnappedLocationProvider (Application application)
Obtains an instance of the RoadSnappedLocationProvider
, which can be used to subscribe
to road-snapped user locations. Note that subscribing to road-snapped location updates may
cause battery drain or unintentional collection of user location data if left running in the
background.
A Navigator
must be successfully obtained before calling this method, otherwise it
will return null
.
Parameters
application | the current Application
|
---|
public static NavigationTransactionRecorder getTransactionRecorder (Application application)
Obtains an instance of the NavigationTransactionRecorder
, which can be used to record
transactions related to navigation.
This class should be used if and only if your company is billed by Google on a per-transaction basis.
A Navigator
must be successfully obtained before calling this method, otherwise it
will return null
.
Parameters
application | the current Application
|
---|
public static synchronized void initForegroundServiceManager (Application application, Integer notificationId, String defaultMessage, NotificationContentProvider provider)
Initializes the ForegroundServiceManager
instance with provided arguments.
This should only be called if you wish to modify any of the default parameters. Otherwise,
call getForegroundServiceManager(Application)
directly. This method can only be called once and
must be called before getForegroundServiceManager(Application)
.
Parameters
application | the current Application |
---|---|
notificationId | the notification id for the persistent notification |
defaultMessage | the default message to be shown if a provider is not specified |
provider | an implementation of NotificationContentProvider
|
public static void resetTermsAccepted (Application application)
Reset the terms and conditions - for testing. Add a call to this before any calls to NavigationApi
if you want to test the terms and conditions dialog.
Parameters
application | the current application |
---|
public static void showTermsAndConditionsDialog (Activity activity, String companyName, String title, NavigationApi.OnTermsResponseListener listener)
Displays a dialog that directs the user to accept Google's Navigation terms and conditions, using the default look and feel.
Parameters
activity | |
---|---|
companyName | |
title | |
listener |
public static void showTermsAndConditionsDialog (Activity activity, String companyName, String title, TermsAndConditionsUIParams uiParams, NavigationApi.OnTermsResponseListener listener, TermsAndConditionsCheckOption termsAndConditionsCheckOption)
Displays a dialog that directs the user to accept Google's Navigation terms and conditions. If specified, the listener will be called on the UI thread, indicating whether the user accepts the terms and conditions.
Note that the dialog will appear even if the user has previously accepted. This should only
be called if areTermsAccepted(Application)
is false
, because it is not
possible for a user to un-accept the terms and conditions.
Parameters
activity | the Activity on which the dialog will be shown |
---|---|
companyName | your company name, which will be displayed in the terms and conditions dialog |
title | the title of the dialog. If null, the dialog will use the default title. |
uiParams | the parameters used to customize the look and feel of the dialog. If null, the default look and feel is used. |
listener | an optional callback which will be fired when the user accepts or declines the terms and conditions |
termsAndConditionsCheckOption | the TermsAndConditionsCheckOption which specifies
options for checking terms and conditions
|
public static void showTermsAndConditionsDialog (Activity activity, String companyName, NavigationApi.OnTermsResponseListener listener)
Displays a dialog that directs the user to accept Google's Navigation terms and conditions, using the default title and the default look and feel.
Parameters
activity | |
---|---|
companyName | |
listener |