黑莓:提前显示警报/状态/对话框并退出
假设我有一个典型的 Blackberry 应用程序:
public class MyApp extends UiApplication {
public static void main(String[] args) {
MyApp app = new MyApp();
app.enterEventDispatcher();
}
public MyApp() {
pushScreen(new MyScreen());
}
}
一开始我就注意到缺少强制条件(显示尺寸错误;缺少 SD 卡;某些 IT 策略等)。
有没有办法显示简短的快速消息给用户(以警报/状态/对话框/任何形式)并立即退出 - 没有/在实例化复杂的屏幕/注册加速侦听器/安装复杂的 CleanupRunnable 之前?
我已经尝试过 状态.show()、Dialog.alert() - 它们不起作用(RuntimeException“非事件线程调用的pushModalScreen”):
public class MyScreen extends MainScreen {
public MyScreen() {
if (Display.getWidth() < 400) {
Status.show("Goodbye");
return;
}
}
}
Let's say I have a typical Blackberry app:
public class MyApp extends UiApplication {
public static void main(String[] args) {
MyApp app = new MyApp();
app.enterEventDispatcher();
}
public MyApp() {
pushScreen(new MyScreen());
}
}
and already at the beginning I notice, that a mandatory condition is missing (wrong Display dimensions; missing SD card; some IT policy; etc.)
Is there a way to display a short and quick message to the user (in the form of Alert/Status/Dialog/whatever) and exit straight away - without/before instantiating a complex Screen/registering Acceleration listeners/installing complex CleanupRunnable?
I've tried Status.show(), Dialog.alert() - they do not work (RuntimeException "pushModalScreen called by a non-event thread"):
public class MyScreen extends MainScreen {
public MyScreen() {
if (Display.getWidth() < 400) {
Status.show("Goodbye");
return;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用invokeLater 代替直接调用。示例如下:
您可以使用 Status.show() 代替 Dialog.inform
Instead of direct invocation use invokeLater. Sample is below:
Instead of Dialog.inform you may use Status.show()
实际上,以下内容比拉斐尔建议的更好 - 因为它下面没有丑陋的白色屏幕。这是我的完整示例 MyApp.java:
Actually the following is better, than what's suggested by Rafael - because it doesn't have the ugly white screen underneath. Here is my complete example MyApp.java: