Launch default webbrowser on clicking hyperlink

34 views
Skip to first unread message

Ivan Codescratch

unread,
Jun 8, 2015, 8:23:39 AM6/8/15
to javafx...@googlegroups.com
Hallo,

 i'm trying to launch Hyperlinks to default browser on Android and iOS.

Does any one have a workaround. Unfortuneately this don't work but on the JavaFX desktop version would.

Hyperlink hyperlink= new Hyperlink("http://www.stackoverflow.com");
hyperlink.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent t) {
getHostServices().showDocument(hyperlink.getText());
}
});

Thank in advance.

Best regards,

Ivan

José Pereda

unread,
Jun 8, 2015, 9:08:01 AM6/8/15
to javafx...@googlegroups.com
You can have a look at Gluon Charm Down library, an open source module for accessing seamlessly the low level platform APIs.

The current version is 0.0.2-SNAPSHOT, so you need to include the maven url on your build.gradle file, along with the different dependencies:

repositories {
    jcenter()
    maven {
    }
}

dependencies {
    compile "com.gluonhq:charm-down-common:0.0.2-SNAPSHOT"
    desktopRuntime "com.gluonhq:charm-down-desktop:0.0.2-SNAPSHOT"
    androidRuntime "com.gluonhq:charm-down-android:0.0.2-SNAPSHOT"
    iosRuntime "com.gluonhq:charm-down-ios:0.0.2-SNAPSHOT"
}

Now on your project, you can use launchExternalBrowser(String url)It will work on desktop, iOS and Android. 

If you are interested in how this is implemented, have a look at the source code here.

Jose

Ivan Maulana

unread,
Jun 8, 2015, 11:27:50 AM6/8/15
to javafx...@googlegroups.com
Hi Jose,

 you save my days. Thanks a lot.

regards,

Ivan
Reply all
Reply to author
Forward
0 new messages