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.
Types are always in the viv.*
namespace, and in the viv.shareVia.*
namespace unless another namespace is specified (for example), viv.rating.*
). All properties have a cardinality of min (Required)
, max (One)
unless otherwise specified.
This reference lists out several of the models available in this library capsule. Some sections contain tables listing information about those concepts or actions.
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.
Property | Type | Kind | Notes |
---|---|---|---|
packageName | PackageName | text | application package name |
activityName | ActivityName | text | activity class name |
activityLabel | ActivityLabel | text | |
appLabel | AppLabel | text | application name |
iconUrl | IconUrl | text | Optional |
This structure contains metadata about whether an application was successfully selected for sharing via the share screen.
Property | Type | Kind | Notes |
---|---|---|---|
appInfo | AppInfo | structure | only set on success |
selectAppResultType | SelectAppResultType | name | (1) |
selectAppResultDescription | SelectAppResultDescription | name | (2) |
result_type_success
, when an application to share with has been selected, or result_type_fail
, in all other cases.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
.result_desc_not_matched
: Bixby could not find an application to share data with.result_desc_matched_more_than_one
: more than one possible application to share with was returned.result_desc_not_exist_search_query
: the SearchQuery
field was empty.This concept is sent to your capsule's action endpoint along with SelectAppResult
.
Property | Type | Kind | Notes |
---|---|---|---|
intentType | IntentType | text | |
intentAction | IntentAction | text | |
intentExtraInfos | IntentExtraInfo | structure | Optional, Many |
One or more of these structures can optionally be included in IntentInfo
to pass data in the form of key/value pairs.
Property | Type | Kind | Notes |
---|---|---|---|
extraName | ExtraName | text | |
extraValue | ExtraValue | text |
This primitive name
concept is used for training purposes.
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)
}
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)
}
}
}
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)
}
}
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.
The following video shows how to incorporate the shareVia
library capsule into your capsule with the library-share-via-example
sample capsule.