---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# NowWebService class - Android

# NowWebService class - Android {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

The NowWebService API provides a function that launches a
NowWebActivity that hosts a web view.
{#NowWebServiceAndroidAPI__entry__3}

| Name | Type | Description |
|-|-|-|
| configuration | [NowServiceConfiguration class - Android](https://servicenow-prod.fluidtopics.net/Csuh2Bp1F37gr9cX8Z4xFg "The NowServiceConfiguration class enables you to configure the ServiceNow instance URL and package name for a feature service.") | Configuration information for the associated service, such as the ServiceNow instance URL and the name of the package. |
[Table 1. Properties]

## NowWebService - launch(context: Context, url: URL, nowWebTheme: NowWebTheme) {#ariaid-title2}

Creates a NowWebActivity that hosts the web view.
{#NWebServ-launch_O_S_O__table_j1k_sbf_qqb__entry__3}{#NWebServ-launch_O_S_O__Web-themeColors-ph}

| Name | Type | Description |
|-|-|-|
| context | Context | Context to use for launching the associated activity. |
| url | URL | URL of the web page to load. This web page must be on the target ServiceNow instance that the service was initialized with. |
| nowWebTheme | [NowWebTheme](https://servicenow-prod.fluidtopics.net/s3IQbwpFndDo~oCEFL6r~w "The NowWebTheme interface provides properties that enable you to override the colors used within web pages hosted on your ServiceNow instance in a native web view.") | Optional. NowWebTheme object to apply to the UI elements of the view controller. Default: Default theme |
[Table 2. Parameters]

{#NWebServ-launch_O_S_O__table_j1k_sbf_qqb} {#NWebServ-launch_O_S_O__table_k1k_sbf_qqb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 3. Returns]

{#NWebServ-launch_O_S_O__table_k1k_sbf_qqb}  
The following code example shows how to call this function.

    suspend fun launchNowWeb() {
        val webService = getNowWebService()

        val webTheme = object : NowWebTheme {
            override val brand: Int
                get() = Color.BLUE

            override val textPrimary: Int
                get() = Color.BLACK

            //Override remaining theme colors
        }
        webService?.launch(activity, URL("https://instance-name.service-now.com"), webTheme)
    }

## NowWebService -- preloadWebCache(preloadUris: List\<URI\>) {#ariaid-title3}

Preloads a list of specified java.net.URIs in a headless webview to pre-populate the webview cache with cacheable resources on the page.
Note:  
Completion of this function call is based on onPageFinished() being called in the webview, which does not take into account redirections or resources on the page. Because of this, preload may not be fully complete when this method returns.
{#NWebServ-preloadWebCache_A__table_pqt_ldl_gyb__entry__3}

| Name | Type | Description |
|-|-|-|
| preloadUris | List | List of java.net.URIs to pre-load. All java.net.URIs must be relative or match the current host configured in the NowSDK. |
[Table 4. Parameters]

{#NWebServ-preloadWebCache_A__table_pqt_ldl_gyb} {#NWebServ-preloadWebCache_A__table_qqt_ldl_gyb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 5. Returns]

{#NWebServ-preloadWebCache_A__table_qqt_ldl_gyb}  
The following example shows how to use the webService.preloadWebCache() function to pre-load the `mesp` page.

    suspend fun preloadNowWeb() {
      val webService = serviceProvider.webService()
      webService.preloadWebCache(
        listOf(
          URI("mesp")
        )
      )
    }

## NowWebService -- updateTheme(nowWebTheme: NowWebTheme) {#ariaid-title4}

Updates the NowWeb UI theme with the specified UI theme. Use this function to update the web UI theme after it has been initially set using the launch() function, such as when changing the theme from light to
dark.
{#NWebServ-updateTheme_O__table_dx5_1rv_x2c__entry__3}

| Name | Type | Description |
|-|-|-|
| nowWebTheme | [NowWebTheme](https://servicenow-prod.fluidtopics.net/s3IQbwpFndDo~oCEFL6r~w "The NowWebTheme interface provides properties that enable you to override the colors used within web pages hosted on your ServiceNow instance in a native web view.") | NowWebTheme object to apply to the UI elements of the view controller. |
[Table 6. Parameters]

{#NWebServ-updateTheme_O__table_dx5_1rv_x2c} {#NWebServ-updateTheme_O__table_ex5_1rv_x2c__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 7. Returns]

{#NWebServ-updateTheme_O__table_ex5_1rv_x2c}  
The following code example shows how to update a light UI theme implemented using the launch() function to the dark UI theme using the updateTheme() function.

    val webService = getNowWebService()

    val lightTheme = object : NowWebTheme {
        override val brand: Int
            get() = Color.BLUE

        override val textPrimary: Int
            get() = Color.BLACK

        override val backgroundPrimary: Int
            get() = Color.WHITE

        // Override remaining theme colors
    }

    val darkTheme = object : NowWebTheme {
        override val brand: Int
            get() = Color.BLUE

        override val textPrimary: Int
            get() = Color.WHITE

        override val backgroundPrimary: Int
            get() = Color.BLACK

        // Override remaining theme colors
    }

    //launch NowWeb with light theme
    webService?.launch(activity, URL("https://instance-name.service-now.com"), lightTheme)

    //update NowWeb with dark theme
    webService?.updateTheme(darkTheme)


