Opening URLs with the browser - RoboVM/iOS
Asked Answered
P

1

9

I have an android game that uses LibGDX. In it, I have some buttons for opening URLs in the browser via:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://myURL/"));
startActivity(intent);

And that seems to work fine...

The problem is that I'm trying to port the game to run on iOS with RoboVM and can't figure out how to setup something similar.

With the RoboVM bindings, I assumed I'd probably want to be using the openURL() method:

openURL (UIApplication application, NSURL url, String sourceApplication, NSObject annotation)

But besides the NSURL, I don't know what I need to be passing for other 3 parameters. And couldn't find any examples online on how to use it.

Philosophy answered 20/1, 2014 at 19:6 Comment(0)
C
19

There is already an abstraction in libgdx that works on all current supported platforms (Android, Desktop, HTML5, and iOS aswell).

Net#openURI

Gdx.net.openURI("https://mcmap.net/q/1140763/-opening-urls-with-the-browser-robovm-ios");

(This is the implementation of RoboVM: RoboVM IOSNet#openURI just as a reference, use the abstraction. No need to make platform specific code when libgdx already did it for you ;) )

Cloistral answered 20/1, 2014 at 20:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.