问题
I have created a JavaFX Application which can be open using a custom scheme myscheme://argument1/argument2
I have successfully implemented the info.plist
file which has the following content:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.myapp.Main</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myscheme</string> // <-- this is the scheme which can open the application
</array>
</dict>
</array>
Now after this i'm successfully able to open my application using archor tag in the html page
<a href="scheme://argument1">Open App</a>
The problem I'm facing is related to the argument, My question is very simple how can I receive arguments in a callback within my application. Right now my main class looks like this:
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Parent root = FXMLLoader.load(getClass().getResource("layouts/main.fxml"));
primaryStage.setTitle(title);
primaryStage.setScene(new Scene(root, screenSize.getWidth() / 2, screenSize.getHeight() / 2));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
I have also tried googling it but couldn't find my answer any help will be appreciated
来源:https://stackoverflow.com/questions/60182607/javafx-application-custom-scheme-uri-handler