1

So I have SparkleAcrivator class

public class SparkleActivator {
    private static boolean sparkleLibLoaded = false;
    //private String downloadLink;
    private String menuItemTitle;

    public native static void initSparkle(String pathToSparkleFramework,
                                          boolean updateAtStartup,
                                          int checkInterval,
                                          /*String downloadLink,*/
                                          String menuItemTitle);

    private boolean updateAtStartup = true;
    private int checkInterval = 86400;

    public SparkleActivator(/*String downloadLink, */String menuItemTitle) {
        //this.downloadLink = downloadLink;
        this.menuItemTitle = menuItemTitle;
    }

    public void start() throws Exception {
        try {
            if(!SparkleActivator.sparkleLibLoaded) {
                System.loadLibrary("sparkle_init");
                SparkleActivator.sparkleLibLoaded = true;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return;
        }

        initSparkle(System.getProperty("user.dir") + "/../../Frameworks/Sparkle.framework",
                updateAtStartup, checkInterval, /*downloadLink, */menuItemTitle);
    }
}

And main class where I start my standalone application and use Sparkle

public static void main(final String... args) {

                if (Helper.isOsx()) {

                    try {
                        sparkleActivator.start();
                    }    catch (Exception e) {
                        new ExceptionHandler(true, 19).handleException(new NotFountSparkleInitException());
                        return;
                    }
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {                             
                                initApp();

                        }
                    });
                }
                else {                  

    }

There problem is Sparkle and my app starts almost simultaneously, but I need wait for action from user in Sparkle window and then start my app.

Thank for any help.

Dmytro Danilenkov
  • 314
  • 1
  • 2
  • 11

1 Answers1

0

What we know is that Sparkle updater requires to be called on the main thread (i.e. GUI thread). Therefore, your app needs to be running to call it. I don't think there is an obvious way to solve this problem. However,...

One way that you can circumvent the issue is to set your app's visibility to false until the user has finished interacting with your updater.

For example, you can add an event listener to your JNI or add listeners to your updater thread. However, the listener on the thread needs to return on user actions instead of when finished.

saqe hi
  • 181
  • 2
  • 8