从通知启动Gluon应用程序的特定视图



我设置了一个警报以显示相应的NotificationNotificationPendingIntent用于启动Gluon App Main类。要显示除主页以外的View,我在postInit方法中调用switchView(otherView)。显示了其他浏览器,但没有AppBar。虽然可以使AppBar出现,但我想知道这是否是正确的方法。

@Override
public void postInit(Scene scene) {
    // additional setUp logic
    boolean showReadingView = (boolean) PlatformProvider.getPlatform().getLaunchIntentExtra("showReadingView", false);
    if (showReadingView) {
        switchView(READING_VIEW);
    }
}

从另一个线程触发与Javafx线程相关的任何内容时,我们必须使用Platform.runLater()

您的情况是这种情况的明确情况:Android线程正在呼吁一些待处理意图,因此,该应用程序再次启动。

这应该完成:

@Override
public void postInit(Scene scene) {
    // additional setUp logic
    boolean showReadingView = (boolean) PlatformProvider.getPlatform().getLaunchIntentExtra("showReadingView", false);
    if (showReadingView) {
        Platform.runLater(() -> switchView(READING_VIEW));
    }
}

相关内容

最新更新