Entry point for the Places API.
Public Method Summary
synchronized static PlacesClient | |
synchronized static void |
deinitialize()
Deinitializes
Places . |
static void |
initialize(Context applicationContext, String apiKey)
Initializes
Places for the given application context with the given API key. |
static void | |
static void |
initializeWithNewPlacesApiEnabled(Context applicationContext, String apiKey)
Initializes
Places for the given application context with the given API key which has
the Places API (New) enabled in the Google Cloud Console. |
static void |
initializeWithNewPlacesApiEnabled(Context applicationContext, String apiKey, Locale locale)
Initializes
Places for the given application context with the given API key which has
the Places API (New) enabled in the Google Cloud Console
This method should only be called once prior to using the Places API. |
synchronized static boolean |
isInitialized()
Returns whether or not
Places has been initialized. |
Inherited Method Summary
Public Methods
public static synchronized PlacesClient createClient (Context context)
Gets an instance of PlacesClient
for a given Context
.
Call initialize(Context, String)
or initialize(Context, String, Locale)
before calling this method.
Parameters
context |
---|
Throws
IllegalStateException | If Places hasn't been initialized first (see initialize(Context, String) or initialize(Context, String, Locale) ).
|
---|
public static synchronized void deinitialize ()
Deinitializes Places
.
This puts Places
into its uninitialized state.
Note: this does not need to be called in order to change the API key by calling initialize(Context, String)
or initialize(Context, String, Locale)
again.
public static void initialize (Context applicationContext, String apiKey)
Initializes Places
for the given application context with the given API key.
All Places API responses are localized using the device's locale. This method should only be
called once prior to using the Places API. You may call this method again to update the API key
used; if so, all widgets and instances of PlacesClient
will now use this new key.
Parameters
applicationContext | The application context in which the Places API will be used in. |
---|---|
apiKey | The Places API key. |
Throws
IllegalArgumentException | If the apiKey is empty.
|
---|
public static void initialize (Context applicationContext, String apiKey, Locale locale)
Initializes Places
for the given application context with the given API key and Locale
.
This method should only be called once prior to using the Places API. You may call this
method again to update the API key and locale used; if so, all widgets and instances of PlacesClient
will now use these new values.
If using this method to initialize within an app which is published as an app bundle, please see documentation to ensure that required resources are available at runtime.
Parameters
applicationContext | The application context in which the Places API will be used in. |
---|---|
apiKey | The Places API key. |
locale | The locale in which Places API responses will be localized. If null, the device locale at the point of request is used. |
Throws
IllegalArgumentException | If the apiKey is empty.
|
---|
public static void initializeWithNewPlacesApiEnabled (Context applicationContext, String apiKey)
Initializes Places
for the given application context with the given API key which has
the Places API (New) enabled in the Google Cloud Console.
All Places API responses are localized using the device's locale. This method should only be
called once prior to using the Places API. You may call this method again to update the API key
used; if so, all widgets and instances of PlacesClient
will now use this new key.
Parameters
applicationContext | The application context in which the Places API will be used in. |
---|---|
apiKey | The Places API key which has the Places API (New) enabled in the Google Cloud Console. |
Throws
IllegalArgumentException | If the apiKey is empty.
|
---|
public static void initializeWithNewPlacesApiEnabled (Context applicationContext, String apiKey, Locale locale)
Initializes Places
for the given application context with the given API key which has
the Places API (New) enabled in the Google Cloud Console
This method should only be called once prior to using the Places API. You may call this
method again to update the API key and locale used; if so, all widgets and instances of PlacesClient
will now use these new values.
If using this method to initialize within an app which is published as an app bundle, please see documentation to ensure that required resources are available at runtime.
Parameters
applicationContext | The application context in which the Places API will be used in. |
---|---|
apiKey | The Places API key which has the Places API (New) enabled in the Google Cloud Console. |
locale | The locale in which Places API responses will be localized. If null, the device locale at the point of request is used. |
Throws
IllegalArgumentException | If the apiKey is empty.
|
---|
public static synchronized boolean isInitialized ()
Returns whether or not Places
has been initialized.