public class

Button

extends ButtonPrivate
java.lang.Object
   ↳ ButtonPrivate
     ↳ com.usebutton.sdk.Button

Class Overview

Main entry point to the Button SDK. There's two steps involved in initializing the Button SDK:

  1. Set your application ID, which you find or create in the Dashboard
  2. Start the SDK in your android.app.Application.onCreate()
<meta-data android:name="com.usebutton.applicationid" android:value="app-0000000000000000"/>
 public class SampleApplication extends android.app.Application {
  public void onCreate() {
      super.onCreate();
      Button.getButton(this).start();
  }
 }

Summary

Public Methods
synchronized static Button getButton(Context context)
Gets the shared Button instance & lazily instantiates if not yet created.
String getReferrerToken()
You can use this method to check if the current user came in through a DLC deep link or not (null)
void handleIntent(Intent intent)
Record inbound deep link for attribution, currently based on getData().
static boolean isStarted()
void logout()
Clears any session information and effectively creates a new customer.
void reportOrder(int valuePennies, String currencyCode, String orderId)
Will report an order attribution and its value & currency to the active referrer token handleIntent(Intent)
void start()
Initializes Button for your application, preferably called from android.app.Application.onCreate().
void stop()
Ceases all Button activity.
void willDisplayPromotion(String buttonId, PlacementContext context, ButtonDropin.Listener listener)
Convenience method to check if a promotion will be filled given a placement ID and context.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static synchronized Button getButton (Context context)

Gets the shared Button instance & lazily instantiates if not yet created.

Returns
  • Button the shared Button instance

public String getReferrerToken ()

You can use this method to check if the current user came in through a DLC deep link or not (null)

Returns

public void handleIntent (Intent intent)

Record inbound deep link for attribution, currently based on getData(). Will see if getData() has a btn_ref=:referrerToken URL parameter on the data provided and record this referrer token for future attribution through reportOrder(int, String, String), see also getReferrerToken().

public static boolean isStarted ()

Returns
  • true if Button have been started. If false, please call .start()

public void logout ()

Clears any session information and effectively creates a new customer. Use when e.g. the user logs out or changes in the host application.

public void reportOrder (int valuePennies, String currencyCode, String orderId)

Will report an order attribution and its value & currency to the active referrer token handleIntent(Intent)

Parameters
valuePennies closest value in pennies, for $4.50 = 450
currencyCode the currency of this order e.g. USD or NOK
orderId your order ID

public void start ()

Initializes Button for your application, preferably called from android.app.Application.onCreate(). Remember to add your application ID to your AndroidManifest.xml first, see Button for example

public void stop ()

Ceases all Button activity.

public void willDisplayPromotion (String buttonId, PlacementContext context, ButtonDropin.Listener listener)

Convenience method to check if a promotion will be filled given a placement ID and context. See ButtonDropin for more information about context. You can use this to e.g. show/hide ButtonDropin's layout container. For instructions on finding your buttonId, see Button

 <com.usebutton.sdk.ButtonDropin
           android:layout_width="match_parent"
           android:layout_height="60dp"
           android:layout_margin="10dp"
           button:buttonId="your-button-id"
           button:textColor="@color/white"
           button:textSize="18dp"
       />
  

Parameters
buttonId same buttonId as you would use in your layout declaration for ButtonDropin
context See ButtonDropin
listener will be called with onPrepared(true) if we will fill a button for this context