Configuring the SDK activities
Configuring the SDK activities
Start each of the SDK's Activity
classes using its builder. The builders provide handy
methods for configuring different aspects of how the activity looks and behaves. Each activity
can start at least one other activity, and multi-activity flows are possible. For example,
the HelpCenterActivity
can start ViewArticleActivity
, RequestListActivity
, and RequestActivity
-
and each of these can in turn start instances of each other. You can provide your configurations
upfront to ensure that the SDK looks and behaves the way you want it to, regardless of which
activity you started or where the user went from there.
Creating a Configuration
Each activity builder has a config()
method which returns an instance of that activity's Configuration
,
which contains all the options you've set on the builder:
Configuration helpCenterConfig = HelpCenterActivity.builder()
.withContactUsButtonVisible(false)
.withLabelNames("my", "labels")
.config();
Starting an Activity with Configurations
You can use these Configuration
objects when calling the show
or intent
methods of any builder.
These take a Context
and optional Configuration
(s) (as a List
or as varargs). This allows you to
start one Support SDK activity and include a configuration for any number of other Support SDK
activity classes. All of the following are valid:
Configuration config1 = ...;
Configuration config2 = ...;
Configuration config3 = ...;
List<Configuration> configList = Arrays.asList(config1, config2, config3);
HelpCenterActivity.builder()
.show(context);
HelpCenterActivity.builder()
.show(context, config1, config3);
HelpCenterActivity.builder()
.show(context, configList);
Creating an Activity Intent
If you want to configure an activity, but don't want to start it straight away, you can use the
builder's intent
method. This returns a regular Android Intent
, which you can start in the usual
way whenever you like.
Intent intent = HelpCenterActivity.builder()
.intent(context, configList);
startActivity(intent);
Using multiple Configurations
The SDK supports configuring each activity once for each "entry-point" to the SDK.
Each call to show
on a builder, or starting a builder's Intent
, can be considered an entry-point.
For example, you can configure RequestActivity
and pass its Configuration
when starting HelpCenterActivity
.
That configuration will be used for any instance of RequestActivity
started subsequently, regardless of whether it is started by HelpCenterActivity
, ViewArticleActivity
or RequestListActivity
.
It's not possible to configure multiple versions of Configuration
for the same
activity, to be used depending on how the user got there. The SDK will iterate through the
collection and use the first appropriate Configuration
that it finds.
Configuration config1 = ...; // Instance of RequestConfiguration
Configuration config2 = ...; // Instance of RequestConfiguration
Configuration config3 = ...; // Instance of RequestConfiguration
HelpCenterActivity.builder()
.show(context, config1, config2, config3); // This is effectively the same as the line below.
HelpCenterActivity.builder()
.show(context, config1);
It is possible to configure multiple versions of Configuration
for the same activity if you are
using them for different entry-points to the SDK.
Configuration config1 = ...; // Instance of RequestConfiguration
Configuration config2 = ...; // Instance of RequestConfiguration
Configuration config3 = ...; // Instance of RequestConfiguration
HelpCenterActivity.builder()
.show(context, config1);
RequestListActivity.builder()
.show(context, config2);
ViewArticleActivity.builder()
.show(context, config3);
For more details, see the the Activity builders reference.