Activity builder reference
Activity builder reference
Each SDK activity has a builder()
method that provides a uniform way of working with the activity.
Example:
RequestActivity.builder()
.show(MyActivity.this);
Sections in this reference:
- HelpCenterActivity builder
- ViewArticleActivity builder
- RequestActivity builder
- RequestListActivity builder
HelpCenterActivity builder
The HelpCenterActivity builder has the following methods:
show
Starts the activity.
Parameter
Name | Type | Comment |
---|---|---|
context | Context | Current state of the application |
Example
HelpCenterActivity.builder()
.show(MyActivity.this);
withArticlesForCategoryIds
Shows only articles in the specified help center categories.
Parameter
Name | Type | Comment |
---|---|---|
categoryIds | Long or List<Long> | One or more category ids |
Example
HelpCenterActivity.builder()
.withArticlesForCategoryIds(112233L, 223344L)
.show(MyActivity.this);
withArticlesForSectionIds
Shows only articles in the specified help center sections.
Parameter
Name | Type | Comment |
---|---|---|
sectionIds | Long or List<Long> | One or more section ids |
Example
HelpCenterActivity.builder()
.withArticlesForSectionIds(112233L, 223344L)
.show(MyActivity.this);
withLabelNames
Shows only articles with all the specified labels. Articles with only some of the labels are ignored.
Parameter
Name | Type | Comment |
---|---|---|
labelNames | String or List<String> | One or more article labels |
Example
HelpCenterActivity.builder()
.withLabelNames("android", "android_o")
.show(MyActivity.this);
withContactUsButtonVisible
Hides the floating action button on the article list view that allows the user to create a ticket.
Parameter
Name | Type | Comment |
---|---|---|
showContactUsButton | boolean | false hides the button |
Example
HelpCenterActivity.builder()
.withContactUsButtonVisible(false)
.show(MyActivity.this);
ViewArticleActivity builder
The ViewArticleActivity shows a specific article in the help center. The builder has the following parameter to specify the article:
Name | Type | Comment |
---|---|---|
article or articleId | Article object or Long | The article to show |
You can pass an Article object returned by an API provider method to open the article. See HelpCenterProvider in the Support SDK Javadocs.
Example:
ViewArticleActivity.builder(123L)
.show(MyActivity.this);
The ViewArticleActivity builder has the following methods:
show
Starts the activity.
Parameter
Name | Type | Comment |
---|---|---|
context | Context | Current state of the application |
Example
ViewArticleActivity.builder(123L, null)
.show(MyActivity.this);
withContactUsButtonVisible
Hides the floating action button on the article that allows the user to create a ticket.
Parameter
Name | Type | Comment |
---|---|---|
contactUsVisible | boolean | false hides the button |
Example
ViewArticleActivity.builder(123L, null)
.withContactUsButtonVisible(false)
.show(MyActivity.this);
intent
Creates an Intent to show the article later. This can be useful with asynchronous operations and Android lifecycle issues.
Parameter
Name | Type | Comment |
---|---|---|
context | Context | Current state of the application |
Example
Intent viewArticleActivityIntent = ViewArticleActivity.builder()
.withContactUsButtonVisible(false)
.intent(MyActivity.this);
config
Creates a Configuration object that can be used to configure all the articles shown in the HelpCenterActivity. After creating the object, pass it to the show
method of the HelpCenterActivity builder.
You can use the following builder methods to configure the activity:
Parameters
- None
Example
Configuration articleConfig = ViewArticleActivity.builder()
.withContactUsButtonVisible(false)
.config();
HelpCenterActivity.builder()
.show(MyActivity.this, articleConfig);
RequestActivity builder
The RequestActivity builder has the following methods:
- show
- withRequestSubject
- withTags
- withFiles
- withCustomFields
- withTicketForm
- withRequestId
- intent
- config
show
Starts the activity.
Parameter
Name | Type | Comment |
---|---|---|
context | Context | Current state of the application |
Example
RequestActivity.builder()
.show(MyActivity.this);
withRequestSubject
Sets a common subject for the tickets.
The ticket form doesn't have a subject field for the user. If you don't set a subject, the activity uses the first 51 characters of the first comment.
Parameter
Name | Type | Comment |
---|---|---|
requestSubject | String | A common subject for each ticket |
Example
RequestActivity.builder()
.withRequestSubject("Android ticket")
.show(MyActivity.this);
withTags
Adds one or more tags to the tickets. By default, no ticket tags are set when the ticket is submitted.
Parameter
Name | Type | Comment |
---|---|---|
tags | String or List<String> | One or more ticket tags |
Example
RequestActivity.builder()
.withTags("android", "mobile")
.show(MyActivity.this);
withFiles
Attaches one or more files to the tickets.
The files appear as pre-selected attachments when the user opens the attachment picker. The files can be un-selected before submitting the request. The files are also visible to the end user in the conversation flow.
Parameter
Name | Type | Comment |
---|---|---|
files | File or List<File> | One or more File objects |
Example
List<File> files = ...;
RequestActivity.builder()
.withFiles(files)
.show(MyActivity.this);
withCustomFields
Adds data to one or more custom ticket fields. Though custom fields are visible to end users in the ticket form in the web version of the help center, the fields can't be displayed in the conversational interface of the SDK. However, you can still use the SDK to set the values of custom fields directly.
An admin in Zendesk Support can add custom ticket fields to the default ticket form. A custom field can be visible to agents only or to both agents and end-users.
Prerequisites
-
The custom ticket field is both visible to, and editable by, end users in the web version of the help center. A Zendesk admin can confirm or set these settings for you. See Adding a custom ticket field for agents and end-users in Zendesk help
-
You have the ticket field's id. To find it, you can use the Ticket Fields API or you can ask a Zendesk admin to get it in Zendesk Support. The admin can get the id on the field's settings page at Admin > Manage > Ticket Fields
Parameter
Name | Type | Comment |
---|---|---|
customField | List<CustomField> | Contains the id of the custom field and the value to assign to it |
Example
CustomField customFieldOne = new CustomField(1234567L, "3");
CustomField customFieldTwo = new CustomField(2345678L, "some_text");
RequestActivity.builder()
.withCustomFields(Arrays.asList(customFieldOne, customFieldTwo))
.show(MyActivity.this);
Note: If your custom field value has multiple words, then the value passed in to ZDKCustomField
should be snake_cased.
withTicketForm
Sets the ticket form and associated custom fields to use in the Zendesk Support agent interface to display tickets submitted with your app. A Zendesk Support admin can create different ticket forms to support multiple request types.
The Support SDK doesn't provide a UI for ticket forms, but with this method you can pass the custom field details to the SDK, along with the ticket form to associate it with. Depending on your use case, this could be information you gather from the end-user through your UI, or details specified in your code.
Prerequisites
-
Your organization is on the Zendesk Suite Enterprise plan or Support Enterprise plan or above
-
A Zendesk Support admin has created one or more ticket forms. See Creating ticket forms to support multiple request types.
-
You have the ticket form's id. You can use the Ticket Forms API to get it. A Zendesk Support admin can also get the id at Admin > Manage > Ticket Forms.
-
You have the IDs for the ticket fields associated with that ticket form. A Zendesk Support admin can get the fields for the ticket form at Admin > Manage > Ticket Forms, and the id for the ticket field at Admin > Manage > Ticket Fields.
-
You have the values for the ticket fields associated with the ticket form. The Support SDK does not provide a UI for ticket forms, so if you need to gather ticket form details from the end-user, you must build your own UI to do that.
Parameter
Name | Type | Comment |
---|---|---|
ticketFormId | Long | The id of the custom form |
customField | List<CustomField> | Contains the id of the custom field and the value to assign to it |
Example
CustomField customFieldOne = new CustomField(1234567L, "3");
CustomField customFieldTwo = new CustomField(2345678L, "some_text");
RequestActivity.builder()
.withTicketForm(1333L, Arrays.asList(customFieldOne, customFieldTwo))
.show(MyActivity.this);
withRequestId
Shows one of the user's tickets and its comments. The user can add a comment to the conversation.
This method is useful to showing a ticket retrieved with the request API provider. See RequestProvider in the Support SDK Javadocs.
Note: This feature is only available on the Team, Professional, and Enterprise plans.
Parameter
Name | Type | Comment |
---|---|---|
requestId | String | The id of the ticket |
Example
RequestActivity.builder()
.withRequestId("123")
.show(MyActivity.this);
intent
Creates an Intent to show the ticket form later. This can be useful with asynchronous operations and Android lifecycle issues.
Parameter
Name | Type | Comment |
---|---|---|
context | Context | Current state of the application |
Example
Intent requestActivityIntent = RequestActivity.builder()
.withRequestSubject("Android ticket")
.intent(MyActivity.this);
config
Returns a Configuration object that can be used to configure the ticket form in other activities. After creating the object, pass it to the show
method of the other activity.
For example, both the RequestListActivity and HelpCenterActivity lets users use a ticket form to submit requests. To configure their ticket form, create a Configuration object with your configuration settings (subject, tags, files, etc) and pass it to the show
method of those activities when you start them.
You can use the following builder methods to configure the ticket form:
Parameters
- None
Example
Configuration requestActivityConfig = RequestActivity.builder()
.withRequestSubject("Android ticket")
.withTags("android", "mobile")
.config();
RequestListActivity.builder()
.show(MyActivity.this, requestActivityConfig);
RequestListActivity builder
The RequestListActivity builder has the following methods:
show
Shows a list of the user's tickets. Tapping a ticket in the list shows the ticket conversation. The user can add a comment to the conversation.
If you're using an anonymous identity, the user can only see the requests they created on the device. If you're using an anonymous identity and the user reinstalls the app, the user won't see any requests they created on the device before reinstalling.
Prerequisites
- A Zendesk admin has enabled Conversations for your app in Zendesk Support. See Configuring the SDK in Zendesk Support in Zendesk help
Parameter
Name | Type | Comment |
---|---|---|
context | Context | Current state of the application |
Example
RequestListActivity.builder()
.show(MyActivity.this);