Introduction
FromIf you don't have a Mapbox account, , and then navigate to your . Copy your default public token to your clipboard. After you've added the Maps SDK as a dependency inside of your Android project, open the R.strings.xml
file, create a new String resource, and paste the access token.
<string name="mapbox_access_token">MAPBOX_ACCESS_TOKEN</string>
Then to pass this into the Maps SDK, you'll want to place the access token inside of your application's onCreate()
method.
The Maps SDK also provides a setToken()
method in case you want to switch the Mapbox access token at runtime. Certain Mapbox APIs require special Mapbox tokens, such as maps in China. Setting a new token enables use of multiple Mapbox tools in conjunction with one another. This method allows you to set a token before a specific Mapbox tool is used instead of setting the token initially and being required to use the same token for all Mapbox-related requests.