【问题标题】:Start specific view of Gluon App from a notification从通知启动 Gluon App 的特定视图
【发布时间】:2016-06-19 21:47:33
【问题描述】:

我设置了一个闹钟来显示对应的NotificationNotificationPendingIntent 用于启动 Gluon App 主类。为了显示除 homeView 之外的 View,我在 postInit 方法中调用 switchView(otherView)。显示了 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);
    }
}

【问题讨论】:

  • 您是否尝试过使用Platform.runLater()?请注意,该事件来自 Android 层,在后台线程中。
  • 是的,行得通。谢谢
  • 我会添加它作为答案然后

标签: gluon gluon-mobile


【解决方案1】:

当从另一个线程触发与 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));
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多