## Button

Main entry point to the Button SDK.

## Summary

| Nested Classes |
| --- |
| class | [Button.InvalidAppIdException](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.InvalidAppIdException.html) | Exception class when an Application id is invalid. |
| interface | [Button.OnConfigureListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.OnConfigureListener.html) | Completion listener for `configure(Context, String, OnConfigureListener)`. |

| Public Constructors |
| --- |
|  | [Button](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#Button())() |

| Public Methods |
| --- |
| static<br> <br> [ButtonActionsInterface](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/action/ButtonActionsInterface.html) | [actions](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#actions())()<br> <br> <br>_This method is deprecated._<br>_Button Actions has been deprecated. Please contact Button to update your integration._ |
| static<br> <br> [Boost](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/boost/Boost.html) | [boost](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#boost())() |
| static<br> <br> void | [clearAllData](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#clearAllData())()<br> <br> <br>Discards the current session and all persisted data. |
| static<br> <br> [Configuration](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/configuration/Configuration.html) | [configuration](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#configuration())()<br> <br> <br>Button SDK feature configuration. |
| static<br> <br> void | [configure](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#configure(Context,%20java.lang.String))(Context context, [String](https://d.android.com/reference/java/lang/String.html) applicationId)<br> <br> <br>Configures `Button` with your application id. |
| static<br> <br> void | [configure](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#configure(Context,%20java.lang.String,%20com.usebutton.sdk.Button.OnConfigureListener))(Context context, [String](https://d.android.com/reference/java/lang/String.html) applicationId, [Button.OnConfigureListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.OnConfigureListener.html) listener)<br> <br> <br>Configures `Button` with your application id. |
| static<br> <br> [DebugInterface](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/debug/DebugInterface.html) | [debug](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#debug())()<br> <br> <br>Debug the Button SDK. |
| static<br> <br> void | [onLocaleChanged](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#onLocaleChanged(Context))(Context context)<br> <br> <br>Call this if you need to have the Button SDK reload its language settings from `Locale.getDefault()` (in case you're forcing a different language in your app from the device default. |
| static<br> <br> void | [openURL](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#openURL(java.lang.String,%20java.lang.String,%20com.usebutton.sdk.OnUrlOpenedListener))( [String](https://d.android.com/reference/java/lang/String.html) url, [String](https://d.android.com/reference/java/lang/String.html) title, [OnUrlOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/OnUrlOpenedListener.html) listener)<br> <br> <br>_This method is deprecated._<br>_use `openURL(String, BrowserConfig, OnBrowserOpenedListener)`._ |
| static<br> <br> void | [openURL](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#openURL(java.lang.String,%20java.lang.String,%20java.lang.String,%20com.usebutton.sdk.OnUrlOpenedListener))( [String](https://d.android.com/reference/java/lang/String.html) url, [String](https://d.android.com/reference/java/lang/String.html) title, [String](https://d.android.com/reference/java/lang/String.html) subtitle, [OnUrlOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/OnUrlOpenedListener.html) listener)<br> <br> <br>_This method is deprecated._<br>_use `openURL(String, BrowserConfig, OnBrowserOpenedListener)`._ |
| static<br> <br> void | [openURL](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#openURL(java.lang.String))( [String](https://d.android.com/reference/java/lang/String.html) url)<br> <br> <br>Asynchronously open a given URL. |
| static<br> <br> void | [openURL](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#openURL(java.lang.String,%20com.usebutton.sdk.browser.BrowserConfig,%20com.usebutton.sdk.browser.OnBrowserOpenedListener))( [String](https://d.android.com/reference/java/lang/String.html) url, [BrowserConfig](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/browser/BrowserConfig.html) config, [OnBrowserOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/browser/OnBrowserOpenedListener.html) listener)<br> <br> <br>Asynchronously open a given URL. |
| static<br> <br> void | [openURL](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#openURL(java.lang.String,%20com.usebutton.sdk.browser.OnBrowserOpenedListener))( [String](https://d.android.com/reference/java/lang/String.html) url, [OnBrowserOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/browser/OnBrowserOpenedListener.html) listener)<br> <br> <br>Asynchronously open a given URL. |
| static<br> <br> void | [openURL](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#openURL(java.lang.String,%20com.usebutton.sdk.OnUrlOpenedListener))( [String](https://d.android.com/reference/java/lang/String.html) url, [OnUrlOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/OnUrlOpenedListener.html) listener)<br> <br> <br>_This method is deprecated._<br>_use `openURL(String, BrowserConfig, OnBrowserOpenedListener)`._ |
| static<br> <br> void | [openURL](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#openURL(java.lang.String,%20com.usebutton.sdk.browser.BrowserConfig))( [String](https://d.android.com/reference/java/lang/String.html) url, [BrowserConfig](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/browser/BrowserConfig.html) config)<br> <br> <br>Asynchronously open a given URL. |
| static<br> <br> [Personalization](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/personalization/Personalization.html) | [personalization](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#personalization())()<br> <br> <br>Personalize your user's experience. |
| static<br> <br> [PurchasePathInterface](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/purchasepath/PurchasePathInterface.html) | [purchasePath](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#purchasePath())()<br> <br> <br>Button Purchase Path takes regular merchant URLs to products, categories or just the homepage and replaces them with a fully attributed Button Purchase Path, optimized for both conversion and user experience. |
| static<br> <br> [User](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/user/User.html) | [user](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.html#user())()<br> <br> <br>Associate your user with a Button session. |

Buttons provide relevant actions to your users, complete with a corresponding UI. Buttons can be configured with one or more merchants that they can offer to your users.

```java
ActionQuery query = ActionQuery.withSubjectLocation(new Location(40.71, 74.0));
ActionRequest request = new ActionRequest("btn-abc123", query);
Button.actions().fetch(reservationRequest, new ActionListener() {@Override
    public void onComplete(@Nullable ButtonAction action, @Nullable Throwable t) {
        if (action != null) {
            action.start(context);
        }
    }
});
```

#### Returns

- Button Actions API

#### public static [Boost](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/boost/Boost.html) boost()

##### Returns

- Boost API

#### public static void clearAllData()

Discards the current session and all persisted data.

Call this method in your log out handler if/when your user logs out of your app.

#### public static [Configuration](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/configuration/Configuration.html) configuration()

Button SDK feature configuration.

##### Returns

- Button configuration API

#### public static void configure(Context context, [String](https://d.android.com/reference/java/lang/String.html) applicationId)

Configures `Button` with your application id.

This method should be called from your `Application.onCreate()`.

##### Parameters

| context | Context you application context. |
| applicationId | your Button application id found at https://app.usebutton.com/. |

#### public static void configure(Context context, [String](https://d.android.com/reference/java/lang/String.html) applicationId, [Button.OnConfigureListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/Button.OnConfigureListener.html) listener)

Configures `Button` with your application id. This method should be called from your `Application.onCreate()`.

##### Parameters

| context | Context you application context. |
| applicationId | your Button application id found at https://app.usebutton.com/. |
| listener | optional callback when configuration is complete. |

#### public static [DebugInterface](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/debug/DebugInterface.html) debug()

Debug the Button SDK.

Enable debug logging during integration for more visibility.

```java
if (BuildConfig.DEBUG) {
     Button.debug().setLoggingEnabled(true);
}
```

##### Returns

- Button debug API

#### public static void onLocaleChanged(Context context)

Call this if you need to have the Button SDK reload its language settings from `Locale.getDefault()` (in case you're forcing a different language in your app from the device default.

#### public static void openURL( [String](https://d.android.com/reference/java/lang/String.html) url, [String](https://d.android.com/reference/java/lang/String.html) title, [OnUrlOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/OnUrlOpenedListener.html) listener)

**This method is deprecated.**

use `openURL(String, BrowserConfig, OnBrowserOpenedListener)`.

Asynchronously open a given URL.

You can use this method to open links to Brands regardless of their partnership status with Button. Please contact your PSM to enable support for non-Button Brands. For such Brands, you may pass a title to provide your users with a cohesive experience.

##### Parameters

| url | the link to open |
| title | optional browser title |
| listener | optional completion listener |

#### public static void openURL( [String](https://d.android.com/reference/java/lang/String.html) url, [String](https://d.android.com/reference/java/lang/String.html) title, [String](https://d.android.com/reference/java/lang/String.html) subtitle, [OnUrlOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/OnUrlOpenedListener.html) listener)

**This method is deprecated.**

use `openURL(String, BrowserConfig, OnBrowserOpenedListener)`.

Asynchronously open a given URL.

You can use this method to open links to Brands regardless of their partnership status with Button. Please contact your PSM to enable support for non-Button Brands. For such Brands, you may pass a title and subtitle to provide your users with a cohesive experience.

N.B. if you provide the subtitle, you must provide the title as well!

##### Parameters

| url | the link to open |
| title | optional browser title |
| subtitle | optional browser subtitle |
| listener | optional completion listener |

#### public static void openURL( [String](https://d.android.com/reference/java/lang/String.html) url)

Asynchronously open a given URL.

You can use this method to open links to Brands regardless of their partnership status with Button. Please contact your PSM to enable support for non-Button Brands.

##### Parameters

| url | the link to open |

#### public static void openURL( [String](https://d.android.com/reference/java/lang/String.html) url, [BrowserConfig](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/browser/BrowserConfig.html) config, [OnBrowserOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/browser/OnBrowserOpenedListener.html) listener)

Asynchronously open a given URL.

##### Parameters

| url | the link to open |
| config | the configuration object used to change title, set pub-ref etc. |
| listener | the completion listener |

#### public static void openURL( [String](https://d.android.com/reference/java/lang/String.html) url, [OnBrowserOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/browser/OnBrowserOpenedListener.html) listener)

Asynchronously open a given URL.

##### Parameters

| url | the link to open |
| listener | the completion listener |

#### public static void openURL( [String](https://d.android.com/reference/java/lang/String.html) url, [OnUrlOpenedListener](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/OnUrlOpenedListener.html) listener)

**This method is deprecated.**

use `openURL(String, BrowserConfig, OnBrowserOpenedListener)`.

Asynchronously open a given URL.

##### Parameters

| url | the link to open |
| listener | optional completion listener |

#### public static void openURL( [String](https://d.android.com/reference/java/lang/String.html) url, [BrowserConfig](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/browser/BrowserConfig.html) config)

Asynchronously open a given URL.

##### Parameters

| url | the link to open |
| config | the configuration object used to change title, set pub-ref etc. |

#### public static [Personalization](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/personalization/Personalization.html) personalization()

Personalize your user's experience.

##### Returns

- Button Personalization API

#### public static [PurchasePathInterface](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/purchasepath/PurchasePathInterface.html) purchasePath()

Button Purchase Path takes regular merchant URLs to products, categories or just the homepage and replaces them with a fully attributed Button Purchase Path, optimized for both conversion and user experience.

##### Returns

- Purchase Path API

#### public static [User](https://building.usebutton.com/button-android/latest/reference/com/usebutton/sdk/user/User.html) user()

Associate your user with a Button session.

You can associate all Button activity with one of your users by setting their user identifier. This can be your user ID, email or a stable hash of one. You can use this later to look up orders, activity and identify the user using Webhooks.
