在启动画面期间获取背景位置

Get Background location During Splash Screen

我的应用程序要求我在启动画面过程中获取用户的当前位置。我通过在 init() 中调用 detectLocation() 来实现它,实际上它是我 init 的第一行。它有效,但挑战在于它在检测位置时显示黑屏。

如何在不黑屏的情况下无缝执行此过程。

您不应该在 init(Object)start() 通话期间这样做。您应该让它们完成,然后才获取位置。例如:

mySpalsh.addShowListener(e -> backgroundLocation());
mySplash.show();

根据您获取背景位置的方式,您可能需要进一步推迟此操作,例如:

mySpalsh.addShowListener(e -> callSerially(() -> backgroundLocation()));
mySplash.show();