Bixby Developer Center

Guides

Refreshing Your Content

Definition and Implementation

You might have instances in your capsule where you need to poll your content provider with updated information, for example if you need to update the contents displayed to your user about some information. In these cases, you can use the refresh reference key in a result-view, input-view, or confirmation-view file to accomplish this. Refreshes are especially useful when updating a user on the current status of an Activity, such as the location of a user's last order. However, you do not need to have an Activity to use a refresh.

For example, you might want to create a ride-sharing capsule. In order for users to get live updates of when their ride will arrive, you can update the views with refresh in your view file, like in this example from the Refreshing Content sample capsule:

  refresh {
if (this.countdown != 0) {
spec {
delay-seconds (5)
with-request {
intent {
goal: CheckRideShareStatus
value {
$expr (this)
}
}
}
}
}
}

View f9713ab on GitHub

Note

Bixby will refresh if and only if the user is still on Bixby. Once they leave Bixby, the refresh will no longer happen.

Refresh Behavior

Refreshing your content affects both your View and the text-to-speech (TTS) that is spoken aloud by Bixby. The Simulator emulates this behavior for you, although the device might react faster. Try on-device testing to be sure of how refreshing will behave.

  • The view will "flash" when the page has been refreshed. This is faster on a device than the Simulator.
  • TTS will be read again when refreshed, even if the text hasn't changed.
  • If the refresh happens too quickly, the TTS from the previous instance might overlap your current instance. This only really happens if your refresh time is too short, such as 1-2 seconds. For a short message such as "Your ride will arrive in 30 seconds", a minimum refresh time of about 5 seconds is recommended. You should make your refresh time reasonable with respect to the event that is happening and the length of the message being said.

Examples

You can find another example of using refresh in the reference page. You can also check out the Refresh Sample Capsule.

To further expand on the ride-sharing example, the refresh key is declared in a result-view file:

result-view {
match {
Activity (this){
min(Required) max (One)
}

}
message {
if (this.countdown != 0) {
template ("Your ride will arrive in #{value(this.countdown)} seconds.")
}
else {
template ("I hope you are enjoying your ride")
}
}
refresh {
if (this.countdown != 0) {
spec {
delay-seconds (5)
with-request {
intent {
goal: CheckRideShareStatus
value {
$expr (this)
}
}
}
}
}
}
render {
layout {
macro (activity-map-macro) {
param (activity) {
expression (this)
}
}
}
}
}

View master on GitHub

This Activity.view.bxb file displays to users the details of the ride-share status. The delay-seconds key handles how often the view is refreshed, which is checked using a conditional for the countdown property. The with-request key has an intent to execute during each refresh interval. It calls the CheckRideShareStatus:

action (CheckRideShareStatus) {
type (Calculation)

collect {
input (activity) {
type (Activity)
min (Required)
default-init {
intent {
goal: Activity
value: Countdown (20)
}
}
}
}

output (Activity)
}

View master on GitHub

Once the ride is over (in this case, when the countdown reaches zero), the refresh will stop.

Note

If you have a transactional capsule and you need to access information from a content provider, in order to get a refreshed state of the action, that action needs to be of the type RefreshActivity. To learn more about how to use Activity Cards to update users during Refresh Activity, see Updates with Activity Cards.