Package com.mapbox.mapboxsdk

Contains the Mapbox Maps Android API classes.

Types

Name Summary
AccountsManager
open class AccountsManager
REMOVAL OR MODIFICATION OF THE FOLLOWING CODE VIOLATES THE MAPBOX TERMS OF SERVICE The following code is used to access Mapbox’s Mapping APIs.
LibraryLoader
abstract class LibraryLoader
Loads the mapbox-gl shared library By default uses System.
LibraryLoaderProvider
interface LibraryLoaderProvider
Injects the default library loader.
Mapbox
@UiThread()
class Mapbox
The entry point to initialize the Mapbox Android SDK.
MapStrictMode
open class MapStrictMode
Using this class you can enable a strict mode that will throw the MapStrictModeException whenever the map would fail silently otherwise.
MapStrictModeException
open class MapStrictModeException : RuntimeException
ModuleProvider
interface ModuleProvider
Injects concrete instances of configurable abstractions
ModuleProviderImpl
open class ModuleProviderImpl : ModuleProvider

AccountsManager

open class AccountsManager

REMOVAL OR MODIFICATION OF THE FOLLOWING CODE VIOLATES THE MAPBOX TERMS OF SERVICE

The following code is used to access Mapbox’s Mapping APIs.

Removal or modification of this code when used with Mapbox’s Mapping APIs can result in termination of your agreement and/or your account with Mapbox.

Using this code to access Mapbox Mapping APIs from outside the Mapbox Maps SDK also violates the Mapbox Terms of Service. On Android, Mapping APIs should be accessed using the methods documented at https://www.mapbox.com/android.

You can access the Mapbox Terms of Service at https://www.mapbox.com/tos/

Constructors

Name Summary
AccountsManager open fun AccountsManager()
AccountsManager open fun AccountsManager(sharedPreferences: SharedPreferences)

Functions

Name Summary
getNow
open fun getNow(): Long
isExpired
open fun isExpired(now: Long, then: Long): Boolean

getNow

open fun getNow(): Long

isExpired

open fun isExpired(now: Long, then: Long): Boolean

LibraryLoader

abstract class LibraryLoader

Loads the mapbox-gl shared library

By default uses System.loadLibrary use setLibraryLoader to provide an alternative library loading hook.

Functions

Name Summary
load
open fun load()
Loads “libmapbox-gl.so” native shared library.
abstract fun load(name: String)
setLibraryLoader
open fun setLibraryLoader(libraryLoader: LibraryLoader)
Set the library loader that loads the shared library.

load

open fun load()

Loads “libmapbox-gl.so” native shared library.

Catches UnsatisfiedLinkErrors and prints a warning to logcat.

abstract fun load(name: String)

setLibraryLoader

open fun setLibraryLoader(libraryLoader: LibraryLoader)

Set the library loader that loads the shared library.

Parameters
Name Summary
libraryLoader
the library loader
   
   

LibraryLoaderProvider

interface LibraryLoaderProvider

Injects the default library loader.

Functions

Name Summary
getDefaultLibraryLoader
abstract fun getDefaultLibraryLoader(): LibraryLoader
Creates and returns a the default Library Loader.

Inheritors

Name
LibraryLoaderProviderImpl

getDefaultLibraryLoader

abstract fun getDefaultLibraryLoader(): LibraryLoader

Creates and returns a the default Library Loader.

Return

the default library loader

MapStrictMode

open class MapStrictMode

Using this class you can enable a strict mode that will throw the MapStrictModeException whenever the map would fail silently otherwise.

Functions

Name Summary
strictModeViolation
open fun strictModeViolation(message: String)
open fun strictModeViolation(throwable: Throwable)
open fun strictModeViolation(message: String, throwable: Throwable)
Internal use.

Properties

Name Summary
strictModeEnabled private open var strictModeEnabled: Boolean

strictModeEnabled

private open var strictModeEnabled: Boolean

strictModeViolation

open fun strictModeViolation(message: String)
open fun strictModeViolation(message: String, throwable: Throwable)
open fun strictModeViolation(throwable: Throwable)

Internal use. Called whenever the strict mode violation occurs.

MapStrictModeException

open class MapStrictModeException : RuntimeException

Constructors

Name Summary
MapStrictModeException open fun MapStrictModeException(message: String)

Functions

Name Summary
addSuppressed
fun addSuppressed(exception: Throwable)
fillInStackTrace
open fun fillInStackTrace(): Throwable
getCause
open fun getCause(): Throwable
getLocalizedMessage
open fun getLocalizedMessage(): String
getMessage
open fun getMessage(): String
getStackTrace
open fun getStackTrace(): Array
getSuppressed
fun getSuppressed(): Array
initCause
open fun initCause(cause: Throwable): Throwable
printStackTrace
open fun printStackTrace()
setStackTrace
open fun setStackTrace(stackTrace: Array)
toString
open fun toString(): String

Mapbox

@UiThread()

class Mapbox

The entry point to initialize the Mapbox Android SDK.

Obtain a reference by calling getInstance. Usually this class is configured in Application#onCreate() and is responsible for the active access token, application context, and connectivity state.

Constructors

Name Summary
Mapbox open fun Mapbox(context: Context, accessToken: String)

Functions

Name Summary
getApplicationContext
@NonNull()
open fun getApplicationContext(): Context
Application context
getInstance
@UiThread()
@NonNull()
open fun getInstance(context: Context, accessToken: String): Mapbox
Get an instance of Mapbox.
hasInstance
open fun hasInstance(): Boolean
Internal use.
isAccessTokenValid
open fun isAccessTokenValid(accessToken: String): Boolean
Runtime validation of Mapbox access token
isConnected
open fun isConnected(): Boolean
Determines whether we have an internet connection available.
setConnected
open fun setConnected(connected: Boolean)
Manually sets the connectivity state of the app.
throwIfAccessTokenInvalid
open fun throwIfAccessTokenInvalid(accessToken: String)
Throws exception when access token is invalid

Properties

Name Summary
accessToken @Nullable()
private open var accessToken: String
moduleProvider private open val moduleProvider: ModuleProvider

accessToken

@Nullable()

private open var accessToken: String

getApplicationContext

@NonNull()

open fun getApplicationContext(): Context

Application context

Return

the application context

getInstance

@UiThread()
@NonNull()

open fun getInstance(context: Context, accessToken: String): Mapbox

Get an instance of Mapbox.

This class manages the Mapbox access token, application context, and connectivity state.

Return

the single instance of Mapbox

Parameters
Name Summary
context
Android context which holds or is an application context
accessToken
Mapbox access token
   
   

hasInstance

open fun hasInstance(): Boolean

Internal use. Check if the INSTANCE is present.

isAccessTokenValid

open fun isAccessTokenValid(accessToken: String): Boolean

Runtime validation of Mapbox access token

Return

true is valid, false otherwise

Parameters
Name Summary
accessToken
the access token to validate
   
   

isConnected

open fun isConnected(): Boolean

Determines whether we have an internet connection available. Please do not rely on thismethod in your apps. This method is used internally by the SDK.

Return

true if there is an internet connection, false otherwise

moduleProvider

private open val moduleProvider: ModuleProvider

setConnected

open fun setConnected(connected: Boolean)

Manually sets the connectivity state of the app. This is useful for apps which control theirown connectivity state and want to bypass any checks to the ConnectivityManager.

Parameters
Name Summary
connected
flag to determine the connectivity state, true for connected, false fordisconnected, and null for ConnectivityManager to determine.
   
   

throwIfAccessTokenInvalid

open fun throwIfAccessTokenInvalid(accessToken: String)

Throws exception when access token is invalid

ModuleProvider

interface ModuleProvider

Injects concrete instances of configurable abstractions

Functions

Name Summary
createHttpRequest
@NonNull()
abstract fun createHttpRequest(): HttpRequest
Create a new concrete implementation of HttpRequest.
createLibraryLoaderProvider
@NonNull()
abstract fun createLibraryLoaderProvider(): LibraryLoaderProvider
Get the concrete implementation of LibraryLoaderProvider

Inheritors

Name
ModuleProviderImpl

createHttpRequest

@NonNull()

abstract fun createHttpRequest(): HttpRequest

Create a new concrete implementation of HttpRequest.

Return

a new instance of an HttpRequest

createLibraryLoaderProvider

@NonNull()

abstract fun createLibraryLoaderProvider(): LibraryLoaderProvider

Get the concrete implementation of LibraryLoaderProvider

Return

a new instance of LibraryLoaderProvider

ModuleProviderImpl

open class ModuleProviderImpl : ModuleProvider

Functions

Name Summary
createHttpRequest
@NonNull()
open fun createHttpRequest(): HttpRequest
Create a new concrete implementation of HttpRequest.
createLibraryLoaderProvider
@NonNull()
open fun createLibraryLoaderProvider(): LibraryLoaderProvider
Get the concrete implementation of LibraryLoaderProvider

createHttpRequest

@NonNull()

open fun createHttpRequest(): HttpRequest

Create a new concrete implementation of HttpRequest.

Return

a new instance of an HttpRequest

createLibraryLoaderProvider

@NonNull()

open fun createLibraryLoaderProvider(): LibraryLoaderProvider

Get the concrete implementation of LibraryLoaderProvider

Return

a new instance of LibraryLoaderProvider