Difference between revisions of "Share.share"
From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>") |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | + | '''Available since:''' Gideros 2020.7<br/> | |
− | ''' | + | '''Class:''' [[Share]]<br/> |
− | ''' | + | |
− | === | + | === Description === |
− | + | Share a piece of data with an external app. This invokes the platform default sharing dialog, allowing to save, print, send, share, etc. | |
+ | <syntaxhighlight lang="lua"> | ||
+ | Share.share(mimeType,data) | ||
+ | </syntaxhighlight> | ||
+ | |||
Supported MIME types: | Supported MIME types: | ||
− | * text/* | + | * '''"text/*"''' |
− | * image/png | + | * '''"image/png"''' |
− | * image/jpeg | + | * '''"image/jpeg"''' |
− | </ | + | === Parameters === |
+ | '''mimeType''': (string) the MIME type of the data<br/> | ||
+ | '''data''': (string) the data itself<br/> | ||
+ | |||
+ | === Example === | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
− | + | local b = Buffer.new("diploma.jpg") | |
+ | rt:save("|B|diploma.jpg") | ||
+ | local bdata = b:get() | ||
+ | b = nil | ||
+ | collectgarbage() | ||
+ | print("DIPLOMA:", #bdata) | ||
+ | local ok, share = pcall(function() return require "Share" end) | ||
+ | if ok then | ||
+ | -- Analytics("diploma_share") | ||
+ | share.share("image/jpeg", bdata) | ||
+ | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
{{Share}} | {{Share}} |
Revision as of 18:25, 18 February 2025
Available since: Gideros 2020.7
Class: Share
Description
Share a piece of data with an external app. This invokes the platform default sharing dialog, allowing to save, print, send, share, etc.
Share.share(mimeType,data)
Supported MIME types:
- "text/*"
- "image/png"
- "image/jpeg"
Parameters
mimeType: (string) the MIME type of the data
data: (string) the data itself
Example
local b = Buffer.new("diploma.jpg")
rt:save("|B|diploma.jpg")
local bdata = b:get()
b = nil
collectgarbage()
print("DIPLOMA:", #bdata)
local ok, share = pcall(function() return require "Share" end)
if ok then
-- Analytics("diploma_share")
share.share("image/jpeg", bdata)
end