Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

NowSDK- Android

The NowSDK class is a singleton that provides the public API for the NowSDK. This class is the gateway to all Android SDK feature services.

Before initializing a feature service, you must initialize the SDK itself by calling NowSDK.configure(). For additional information on getting started with the Android NowSDK, refer to the ServiceNow Mobile SDK Developers Guide - Android.

Parent Topic:Mobile SDK - Android

NowSDK - configure(application: Application, configuration: NowSDKConfiguration)

Configures the NowSDK for use.

You must call this function before attempting to use any of the feature services provided by the SDK.

NameTypeDescription
applicationApplicationReference to the hosting application object.
configurationNowServiceConfigurationObject containing the information necessary to initialize the NowSDK.
TypeDescription
NoneNowSDKError is thrown if the provided configuration is invalid.

The following code example shows how to call this function.

class SampleApplication : Application(), NowSDKAuthorizationProviding, DevicePermissionDelegate {

    private val nowSdkSettings = NowSDKSettings(
        instanceBaseURL = "https://instance-name.service-now.com",
        clientId = "client_id",
        user = "user"
    )

    private val coroutineScope = CoroutineScope(Dispatchers.IO)

    private val nowSDKConfiguration = NowSDKConfiguration(this, this, NowLogLevel.Debug)
    override fun onCreate() {
        super.onCreate()

        NowSDK.configure(this, nowSDKConfiguration)
    }


    override fun requestAuthorization(
        instanceURL: URL,
        callback: Consumer<List<AuthorizationToken>?>
    ) {
        coroutineScope.launch {
            when {
                nowSdkSettings.user.isNullOrBlank().not() -> authorizeWithJWT(
                    callback = callback,
                    user = nowSdkSettings.user,
                    clientId = nowSdkSettings.clientId
                )

                else -> authorizeWithGuest(callback = callback)
            }
        }
    }

    override fun canRequestPermission(permission: DevicePermission): Boolean {
        return true
    }
}

NowSDK - logout()

Clears all user sessions persisted in memory.

NameTypeDescription
None  
TypeDescription
None 

The following code example shows how to call this function.

class SampleApplication : Application() {

    private val nowSDKConfiguration = NowSDKConfiguration(authorizationProvider, permissionDelegate, NowLogLevel.Debug)

    override fun onCreate() {
        super.onCreate()
        NowSDK.configure(this, nowSDKConfiguration)
    }

    fun logout() {
        // Clear all user session when an application resets the user session
        NowSDK.logout()
    }
}