Difference between revisions of "Share.share"

From GiderosMobile
Line 6: Line 6:
 
Sharing a piece of data with an external app.
 
Sharing a piece of data with an external app.
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
Share.share(mimeType,data)
+
(bool) = Share.share(mimeType,data)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 19: Line 19:
 
'''mimeType''': (string) the MIME type of the data<br/>
 
'''mimeType''': (string) the MIME type of the data<br/>
 
'''data''': (string) the data itself<br/>
 
'''data''': (string) the data itself<br/>
 +
 +
=== Return values ===
 +
'''Returns''' (boolean) ''true'' if data can be shared<br/>
  
 
=== Example ===
 
=== Example ===

Revision as of 17:36, 20 February 2025

Available since: Gideros 2020.7
Class: Share

Description

Sharing a piece of data with an external app.

(bool) = Share.share(mimeType,data)

This invokes the platform default sharing dialog, allowing to save, print, send, share, etc.

Supported MIME types:

  • "text/*"
  • "image/png"
  • "image/jpeg"

Parameters

mimeType: (string) the MIME type of the data
data: (string) the data itself

Return values

Returns (boolean) true if data can be shared

Example

local share = require "Share"

local tex = Texture.new("gfx/cat.jpg")
local bmp = Bitmap.new(tex)
local rt = RenderTarget.new(tex:getWidth(), tex:getHeight())
rt:draw(bmp)
local buff = Buffer.new("buffer.jpg") -- create a buffer
rt:save("|B|buffer.jpg") -- write to the buffer

local bdata = buff:get()

share.share("image/jpeg", bdata) -- share buffer data