Bixby Developer Center

Guides
References

Sharing (viv.shareVia)

The Bixby viv.shareVia library capsule allows your capsule to send content to other applications, using Android intents. The library provides access to the Android share menu, which lets the user choose a target application to send the shared data to and returns a target name to your capsule.

A sample capsule that demonstrates viv.shareVia is available as library-share-via-example in the Bixby Capsule Samples Collection on GitHub.


Video Tutorial: ShareVia Library - How to Share Stuff in Your Capsule


Models

Note

Types are always in the viv.* namespace, and in the viv.shareVia.* namespace unless another namespace is specified (e.g., viv.rating.*). All properties have a cardinality of min (Required), max (One) unless otherwise specified.

AppInfo

The AppInfo concept contains sharing target activity information. This can be used by your capsule to determine both the application to send data to and the specific data to send.

PropertyTypeKindNotes
packageNamePackageNametextapplication package name
activityNameActivityNametextactivity class name
activityLabelActivityLabeltext
appLabelAppLabeltextapplication name
iconUrlIconUrltextOptional

SelectAppResult

This structure contains metadata about whether an application was successfully selected for sharing via the share screen.

PropertyTypeKindNotes
appInfoAppInfostructureonly set on success
selectAppResultTypeSelectAppResultTypename(1)
selectAppResultDescriptionSelectAppResultDescriptionname(2)
  1. This field contains either the string result_type_success, when an application to share with has been selected, or result_type_fail, in all other cases.
  2. This field offers more description about the failure or success state. It contains one of the following:
    1. result_desc_matched: an application has been selected and the appInfo field has been populated. This will be the value if the result type is result_type_success.
    2. result_desc_not_matched: Bixby could not find an application to share data with.
    3. result_desc_matched_more_than_one: more than one possible application to share with was returned.
    4. result_desc_not_exist_search_query: the SearchQuery field was empty.

IntentInfo

This concept is sent to your capsule's action endpoint along with SelectAppResult.

PropertyTypeKindNotes
intentTypeIntentTypetext
intentActionIntentActiontext
intentExtraInfosIntentExtraInfostructureOptional, Many

IntentExtraInfo

One or more of these structures can optionally be included in IntentInfo to pass data in the form of key/value pairs.

PropertyTypeKindNotes
extraNameExtraNametext
extraValueExtraValuetext

SearchQuery

This primitive name concept is used for training purposes.

Usage

Note

The Sharing capsule does not send the shared contents to the target application; your capsule must implement its own function, accepting IntentInfo and SelectAppResult concepts as inputs.

Your application should implement an action that outputs an IntentInfo concept. One way to do this is to extend IntentInfo and implement a FindIntentInfo action:

structure (IntentInfo) {
extends (shareVia.IntentInfo)
}
action (FindIntentInfo) {
type (Constructor)
collect {
// ... inputs from your capsule ...
}
output (IntentInfo)
}

Your actions might also create IntentInfo as a computed-input.

The shareVia.SearchQuery primitive concept is provided for training purposes, to allow your capsule to respond to utterances such as "share via Facebook":

[g:viv.yourcapsule.shareVia] Share via (Facebook)[v:viv.shareVia.SearchQuery]

There are no actions in viv.shareVia that implement searching on SearchQuery; if you use it as an input for FindIntentInfo (or your capsule's equivalent), you must provide an appropriate domain-specific implementation. Let's use the shareVia sample capsule as an example. It uses the shareVia library to share videos, and its ShareVia action takes a searchQuery and a video as input, returning a ShareViaResult concept.

action (ShareVia) {
description (Share the gif via Android Intent)
type (Constructor)
collect {
input (video) {
type (Video)
min (Required) max (One)
default-init {
intent: goal: GetVideo
}
}

input (searchQuery) {
type (shareVia.SearchQuery)
min (Optional) max (One)
hidden
}

computed-input (intentInfo) {
type (shareVia.IntentInfo)
min (Required) max (One)
compute{
intent {
goal: shareVia.IntentInfo {
intentType: shareVia.IntentType(text/plain)
intentAction: shareVia.IntentAction(android.intent.action.SEND)
}
}
}
}

computed-input (selectAppResult) {
type (shareVia.SelectAppResult)
min (Optional) max (One)
compute {
intent {
goal : shareVia.SelectAppInfo
value : .$expr(intentInfo)
value : .$expr(searchQuery)
}
}
}
}
output (ShareViaResult)
}

View on GitHub

The ShareVia action is implemented in a local endpoint for the sharing action itself. In the endpoints.bxb file, an action-endpoint block receives the IntentInfo and SelectAppResult concepts, along with a video concept for the video being shared.

endpoints {
action-endpoints {
action-endpoint (GetVideo) {
local-endpoint (GetVideo.js)
}
action-endpoint (ShareVia) {
accepted-inputs (video, intentInfo, selectAppResult, $vivContext)
local-endpoint (ShareVia.js)
}
}
}

View on GitHub

The local endpoint, ShareVia.js, uses the properties of the IntentInfo and SelectAppResult concepts to construct the Android intent URI being returned in the ShareViaResult concept.

structure (ShareViaResult) {
description (__DESCRIPTION__)
property (uri) {
type (ShareViaUri)
min (Required) max (One)
}
}

View on GitHub

Note

The Intent URI returned is defined entirely by the application you are linking to. See Create Deep Links to App Content in Android's documentation.