Share.new: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
 
Line 4: Line 4:


=== Description ===
=== Description ===
Sharing a piece of data with an external app.
Creates a new Share object.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
(bool) = Share.new(mimeType,data)
Share.new()
</syntaxhighlight>
</syntaxhighlight>
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<br/>
'''data''': (string) the data itself<br/>
=== Return values ===
'''Returns''' (boolean) ''true'' if data can be shared<br/>


=== Example ===
=== Example ===
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--local share = require "Share"
require "Share"
require "Share"


local share = Share.new()
local share = Share.new()
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
</syntaxhighlight>
</syntaxhighlight>


{{Share}}
{{Share}}

Latest revision as of 18:07, 20 February 2025

Available since: Gideros 2020.7
Class: Share

Description

Creates a new Share object.

Share.new()

Example

require "Share"

local share = Share.new()