public class

ActionQuery

extends Object
java.lang.Object
   ↳ com.usebutton.sdk.action.ActionQuery

This class is deprecated.
Button Actions has been deprecated. Please contact Button to update your integration.

Class Overview

This is the main class holding context information for the current screen of your application. Create an instance of this class and set relevant information representing the information presented to the user so the appropriate button can be created with as much information as possible. An instance of this class can be passed to ActionRequest(String, ActionQuery) to prepare a request to fetch a ButtonAction.

Location Example context for a screen showing information about a restaurant where we want to provide the user with transportation methods from their location to the venue:

 DropinButton button = (DropinButton) findViewById(R.id.button);

 final Location restaurant = new Location("Feast", 40.7325614, -73.988068);
 final ActionQuery query = ActionQuery.withSubjectLocation(restaurant);
 query.setUserLocation(new Location("Work", 40.7382869, -73.9823721));
 final ActionRequest request = new ActionRequest("btn-abc123", query);

 Button.actions().fetch(request, new ActionListener(){
     @Override
     public void onComplete(@Nullable ButtonAction action, @Nullable Throwable t) {
         if(action == null) return;
         button.prepareWithAction(action);
     }
 }
 

Event Example context for a screen showing event information, for example a calendar event. This context information can in turn be used for e.g. on demand parking or nearby restaurants for when the show is over.
 final Event event = new Event("Concert at Madison Square Garden");
 event.setStart(new Date());
 event.setEnd(new Date(System.currentTimeMills() + 3*3600*1000));
 final Location msg = new Location("Madison Square Garden", 40.7505045,-73.9956274);
 event.setLocation(msg);
 

Summary

Public Constructors
ActionQuery()
Public Methods
ActionQuery addItem(Item item)
Add an item to the context, for example the items of a shopping cart or ingredients of a recipe.
static ActionQuery deepCopy(ActionQuery context)
This method will create a new instance of context, creating a deep copy of all values.
ActionQuery setArtist(MusicArtist artist)
Sets an artist object represented by the current screen, for example for a streaming music player you would here set the artist for the track currently playing.
ActionQuery setDate(Date date)
Sets the time and date for the information represented on screen - the time of a reservation, date of a hotel reservation or similar.
ActionQuery setDateRange(Date startDate, Date endDate)
Sets the date range relevant to the current screen, for a concert this could be the start and end time of the concert or the start and end time for a calendar event.
ActionQuery setEvent(Event event)
Sets an event to this context, an example would be a calendar reminder representing a location and start & end time.
ActionQuery setJourney(Journey journey)
Sets a journey object to this context, this will represent for example a trip with a start & end location, travel method and start & end time.
ActionQuery setSubjectLocation(Location location)
Sets the physical location represented by the current screen, this can have coordinates, a structured address or simply just a name.
ActionQuery setURL(Uri uri)
Sets a URL as context, we can use this to enrich the context with more information from the provided URL.
ActionQuery setUserLocation(Location location)
The current location of the user.
static ActionQuery withArtist(MusicArtist artist)
Creates a new ActionQuery instance and calls setArtist(MusicArtist).
static ActionQuery withDate(Date date)
Creates a new ActionQuery instance and calls setDate(Date).
static ActionQuery withDateRange(Date startDate, Date endDate)
Creates a new ActionQuery instance and calls setDateRange(Date, Date).
static ActionQuery withEvent(Event event)
Creates a new ActionQuery instance and calls setEvent(Event).
static ActionQuery withJourney(Journey journey)
Creates a new ActionQuery instance and calls setJourney(Journey).
static ActionQuery withSubjectLocation(Location location)
Creates a new ActionQuery instance and calls setSubjectLocation(Location).
static ActionQuery withUserLocation(Location location)
Creates a new ActionQuery instance and calls setUserLocation(Location).
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ActionQuery ()

Public Methods

public ActionQuery addItem (Item item)

Add an item to the context, for example the items of a shopping cart or ingredients of a recipe.

Returns
  • the same object for chaining calls.

public static ActionQuery deepCopy (ActionQuery context)

This method will create a new instance of context, creating a deep copy of all values. If context is null, null is returned. JSONObject doesn't have a good method to do a deep copy without going to json string and back, so this is not an ideal solution.

Returns
  • a deep copy of context or null.

public ActionQuery setArtist (MusicArtist artist)

Sets an artist object represented by the current screen, for example for a streaming music player you would here set the artist for the track currently playing.

Returns
  • the same object for chaining calls.

public ActionQuery setDate (Date date)

Sets the time and date for the information represented on screen - the time of a reservation, date of a hotel reservation or similar.

Returns
  • the same object for chaining calls.

public ActionQuery setDateRange (Date startDate, Date endDate)

Sets the date range relevant to the current screen, for a concert this could be the start and end time of the concert or the start and end time for a calendar event.

public ActionQuery setEvent (Event event)

Sets an event to this context, an example would be a calendar reminder representing a location and start & end time.

Returns
  • the same object for chaining calls.

public ActionQuery setJourney (Journey journey)

Sets a journey object to this context, this will represent for example a trip with a start & end location, travel method and start & end time.

Returns
  • the same object for chaining calls.

public ActionQuery setSubjectLocation (Location location)

Sets the physical location represented by the current screen, this can have coordinates, a structured address or simply just a name. An example for this would be a restaurant listing or a venue for an event.

Returns
  • the same object for chaining calls.

public ActionQuery setURL (Uri uri)

Sets a URL as context, we can use this to enrich the context with more information from the provided URL.

Returns
  • the same object for chaining calls.

public ActionQuery setUserLocation (Location location)

The current location of the user. Provide whatever level of granularity makes sense for the context / that you have access to.

Returns
  • the same object for chaining calls.

public static ActionQuery withArtist (MusicArtist artist)

Creates a new ActionQuery instance and calls setArtist(MusicArtist).

public static ActionQuery withDate (Date date)

Creates a new ActionQuery instance and calls setDate(Date).

public static ActionQuery withDateRange (Date startDate, Date endDate)

Creates a new ActionQuery instance and calls setDateRange(Date, Date).

public static ActionQuery withEvent (Event event)

Creates a new ActionQuery instance and calls setEvent(Event).

public static ActionQuery withJourney (Journey journey)

Creates a new ActionQuery instance and calls setJourney(Journey).

public static ActionQuery withSubjectLocation (Location location)

Creates a new ActionQuery instance and calls setSubjectLocation(Location).

public static ActionQuery withUserLocation (Location location)

Creates a new ActionQuery instance and calls setUserLocation(Location).