---
schema_version: "1"
id: 789f146cadbdc575926fece3bf353e3a100997665596309bb305459b9a357bd3
title: Business Hours for Android
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/messaging-in-app/guides/android-business-hours.md
canonical_url: https://developer.salesforce.com/docs/service/messaging-in-app/guide/android-business-hours.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 39427ce3b881c612781ef2656cdec92287a7ef56ba371ea7956c0a4810d6ebbf
products:
  - Enhanced In-App Chat
  - Service Cloud Developer Content
---
# Business Hours for Android

If you've set up business hours in Salesforce, use the `retrieveBusinessHours` method to check for business hours and handle things accordingly. For instance, you can hide the chat button outside of business hours. When using the UI SDK, customers see a banner in the chat window when it's outside of business hours.

To configure business hours for your deployment, see [Set Business Hours in Enhanced Chat](https://help.salesforce.com/s/articleView?id=service.miaw_business_hours.htm).


**important:** This feature requires version 1.3.0 or later of the Enhanced In-App Chat SDK.


This article applies to the following implementations:

| UI SDK | Core SDK |
| :----: | :------: |
|   ✅   |    ✅    |


Retrieve the business hours from the core client object using the `retrieveBusinessHours` method, and then determine how to proceed based on that information. This method returns the business hours over the next 24 hours. You can use the helper method `isWithinBusinessHours` to determine whether a time is within business hours; specifying no argument uses the current time.

**note:** This sample requires the configuration object that you created when setting up the UI SDK or the Core SDK. See [Build a UI SDK App](https://developer.salesforce.com/docs/service/messaging-in-app/guide/android-ui-sdk.md) or [Build a Core SDK App](https://developer.salesforce.com/docs/service/messaging-in-app/guide/android-core-sdk.md) for more information.

```kotlin
private val scope = CoroutineScope(Dispatchers.Main + supervisorJob)

fun handleBusinessHours() {

  // Handle business hours suspend function within a scope
  scope.launch {
      // Create a core client from a config
      val coreClient = CoreClient.Factory.create(myContext, config)

      // Get business hours info
      val result = coreClient.retrieveBusinessHours()
      val businessHoursInfo: BusinessHoursInfo? = (result as? Result.Success)?.data

      // Determine whether we're currently within business hours
      if (businessHoursInfo?.isWithinBusinessHours() != false) {
          // TO DO: Handle when we're within business hours
      } else {
          // TO DO: Handle when we're outside of business hours
      }

      // Alternatively, you can inspect the business hours info.
      // For instance, get specific business hours time periods
      // using the businessHoursInfo.businessHours list.
  }
}
```
