Difference between revisions of "love.system.openURL"
(Created page) |
m (→Notes) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 11: | Line 11: | ||
=== Returns === | === Returns === | ||
{{param|boolean|success|Whether the URL was opened successfully.}} | {{param|boolean|success|Whether the URL was opened successfully.}} | ||
+ | |||
+ | == Notes == | ||
+ | Passing <code>file://</code> scheme in Android 7.0 (Nougat) and later always result in [https://developer.android.com/about/versions/nougat/android-7.0-changes.html#sharing-files failure]. Prior to [[11.2]], this will crash LÖVE instead of returning false. | ||
== Examples == | == Examples == | ||
Line 29: | Line 32: | ||
if key == "s" then | if key == "s" then | ||
-- To open a file or folder, "file://" must be prepended to the path. | -- To open a file or folder, "file://" must be prepended to the path. | ||
− | love. | + | love.system.openURL("file://"..love.filesystem.getSaveDirectory()) |
end | end | ||
end | end |
Latest revision as of 03:02, 11 August 2019
Available since LÖVE 0.9.1 |
This function is not supported in earlier versions. |
Opens a URL with the user's web or file browser.
Contents
Function
Synopsis
success = love.system.openURL( url )
Arguments
string url
- The URL to open. Must be formatted as a proper URL.
Returns
boolean success
- Whether the URL was opened successfully.
Notes
Passing file://
scheme in Android 7.0 (Nougat) and later always result in failure. Prior to 11.2, this will crash LÖVE instead of returning false.
Examples
Open love2d.org when the game is loaded.
function love.load()
love.system.openURL("http://love2d.org/")
end
Open the game's save directory when "s" is pressed.
function love.load()
-- Make sure the save directory exists by writing an empty file.
love.filesystem.write("test.txt", "")
end
function love.keypressed(key)
if key == "s" then
-- To open a file or folder, "file://" must be prepended to the path.
love.system.openURL("file://"..love.filesystem.getSaveDirectory())
end
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info