Difference between revisions of "love.system.openURL"

m (Android 7.0 file:// notice.)
m (Notes)
 
Line 13: Line 13:
  
 
== Notes ==
 
== Notes ==
Passing <code>file://</code> scheme in Android 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.
+
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 ==

Latest revision as of 04: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.

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