Share:import: Difference between revisions
From GiderosMobile
Created page with "__NOTOC__ '''Available since:''' Gideros 2024.1<br/> '''Class:''' Share<br/> === Description === Importing a piece of data via the phone default file application. <syntax..." |
No edit summary |
||
| Line 9: | Line 9: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This invokes the platform default file application with the data filtered by extension. | This invokes the platform default file application with the data filtered by MIME type and extension. | ||
=== Parameters === | === Parameters === | ||
| Line 18: | Line 18: | ||
'''Returns''' (boolean) ''true'' if data can be imported<br/> | '''Returns''' (boolean) ''true'' if data can be imported<br/> | ||
=== | === Examples === | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
require "Share" | require "Share" | ||
| Line 25: | Line 25: | ||
share:import("*/*" ,"jpg") -- MIME type, extension | share:import("*/*" ,"jpg") -- MIME type, extension | ||
local function decodeFileData(e) | |||
print("share:import callback:", e and e.status, e and e.mime, e and e.name) | |||
if e and e.status and e.status > 0 then | |||
print("Got Data:", #e.data) | |||
else | |||
print("Import failed") | |||
end | |||
share:removeEventListener(Event.SHARE_IMPORT_RESULT, decodeFileData) | |||
end | |||
share:addEventListener(Event.SHARE_IMPORT_RESULT, decodeFileData) | |||
</syntaxhighlight> | |||
'''Audio''' | |||
<syntaxhighlight lang="lua"> | |||
require "Share" | |||
local share = Share.new() | |||
share:import("audio/x-wav" ,"wav") -- MIME type, extension | |||
local function decodeFileData(e) | local function decodeFileData(e) | ||
Latest revision as of 19:15, 20 February 2025
Available since: Gideros 2024.1
Class: Share
Description
Importing a piece of data via the phone default file application.
(bool) = Share:import(mimeType,extension)
This invokes the platform default file application with the data filtered by MIME type and extension.
Parameters
mimeType: (string) the MIME type of the data
extension: (string) the extension to use as filter
Return values
Returns (boolean) true if data can be imported
Examples
require "Share"
local share = Share.new()
share:import("*/*" ,"jpg") -- MIME type, extension
local function decodeFileData(e)
print("share:import callback:", e and e.status, e and e.mime, e and e.name)
if e and e.status and e.status > 0 then
print("Got Data:", #e.data)
else
print("Import failed")
end
share:removeEventListener(Event.SHARE_IMPORT_RESULT, decodeFileData)
end
share:addEventListener(Event.SHARE_IMPORT_RESULT, decodeFileData)
Audio
require "Share"
local share = Share.new()
share:import("audio/x-wav" ,"wav") -- MIME type, extension
local function decodeFileData(e)
print("share:import callback:", e and e.status, e and e.mime, e and e.name)
if e and e.status and e.status > 0 then
print("Got Data:", #e.data)
else
print("Import failed")
end
share:removeEventListener(Event.SHARE_IMPORT_RESULT, decodeFileData)
end
share:addEventListener(Event.SHARE_IMPORT_RESULT, decodeFileData)