Stay organized with collections
Save and categorize content based on your preferences.
public final class
MapsInitializer
extends Object
Use this class to initialize the Google Maps SDK for Android if features need to be used before
obtaining a map. It must be called because some classes such as BitmapDescriptorFactory and
CameraUpdateFactory need to be initialized.
If you are using MapFragment or MapView and have already obtained a (non-null)
GoogleMap by calling getMapAsync() on either of these classes and waiting for the
onMapReady(GoogleMap map) callback, then you do not need to worry about this class. See
the sample application for some examples.
Initializes the Google Maps SDK for Android so that its classes are ready for use.
Inherited Method Summary
From class
java.lang.Object
boolean
equals(Object arg0)
final
Class<?>
getClass()
int
hashCode()
final
void
notify()
final
void
notifyAll()
String
toString()
final
void
wait(long arg0, int arg1)
final
void
wait(long arg0)
final
void
wait()
Public Methods
public
static
synchronized
int
initialize(Context context)
Initializes the Google Maps SDK for Android so that its classes are ready for use. If you are
using MapFragment or MapView and have already obtained a (non-null) GoogleMap by calling getMapAsync() on either of these classes, then it is not
necessary to call this.
Parameters
context
Required to fetch the necessary SDK resources and code. Must not be null.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-26 UTC."],[[["The `MapsInitializer` class is used to initialize the Google Maps SDK for Android, particularly when features are needed before a map is obtained."],["It's crucial to call `MapsInitializer.initialize()` because classes like `BitmapDescriptorFactory` and `CameraUpdateFactory` require prior initialization."],["If you're using `MapFragment` or `MapView` and have a non-null `GoogleMap` instance through `getMapAsync()`, you don't need to explicitly call `MapsInitializer.initialize()`."],["The `initialize()` method takes a Context as a parameter and returns a `ConnectionResult` error code indicating the success of the initialization."]]],["The `MapsInitializer` class initializes the Google Maps SDK for Android, enabling the use of classes like `BitmapDescriptorFactory` and `CameraUpdateFactory`. It is necessary when map features are used before obtaining a map. Initialization is performed via the `initialize(Context context)` method, which requires a non-null context. This step is not required if a `GoogleMap` is already obtained via `getMapAsync()` on `MapFragment` or `MapView`. The method returns a `ConnectionResult` error code.\n"]]