杀死自定义黑莓应用程序时出现问题

发布于 2024-08-07 09:02:15 字数 667 浏览 5 评论 0原文

我的所有屏幕都来自具有以下 onClose() 方法的屏幕:

    public boolean onClose()
    {
        Dialog.alert("Closing");
        done = true;
        System.exit(0);

        return true;
    }

我有点假设 System.exit(0);实际上会杀死我的应用程序。

如果我点击红色按钮完全退出,我确实会成功收到“关闭”对话框消息。如果我按后退按钮太多次也是如此。但即使我看到“关闭”对话框,当我选择“切换应用程序”时,我仍然会看到我的应用程序在后台运行。

不仅如此,如果我有一个线程正在运行,有时在退出应用程序后我仍然会看到它在运行(这就是为什么我设置了 did 变量,这样如果 did 为 true,我的线程将自动中止)。

最重要的是,如果应用程序崩溃,我绝对看不到我的对话框消息,即使我设法完全离开应用程序。如果我尝试在应用程序崩溃后重新单击该应用程序,它也不会重新加载。曾经。有没有办法优雅地处理这种情况? (显然,我已经为我发现的每个问题提供了错误处理,但如果在野外发生了某些情况,我至少希望应用程序不会继续消耗内存)

黑莓应用程序永远不会关闭吗?我做错了什么吗?现在,如果我希望我的应用程序停止运行,我必须完全删除它并重新安装它!

All of my screens inherent from a screen with the following onClose() method:

    public boolean onClose()
    {
        Dialog.alert("Closing");
        done = true;
        System.exit(0);

        return true;
    }

I kind of assumed that System.exit(0); would actually kill my application.

If I hit the red button to completely exit, I do get a "Closing" dialog message sucessfully. Same if I hit the back button too many times. But even if I get that "Closing" dialog, I'll still see my application running in the background when I select "Switch Application".

Not only that, if I have a thread running, sometimes I'll still see it going after I've quit the application (which is why I have that done variable set, so that my threads will automatically abort if done is true).

And on top of that, if the application crashes, I definitely don't see my dialog message, even if i manage to leave the application entirely. If I try to reclick the application after it's crashed, it doesn't reload, too. Ever. Is there anyway to gracefully handle that situation? (Obviously I have supplied error handling for every problem I've found, but if something happens in the wild, I want at least the application to not continue eating up memory)

Do Blackberry apps just never close? Am I doing something wrong? Right now if I want my application to stop running, I have to completely delete it and reinstall it!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吾性傲以野 2024-08-14 09:02:15

如果您正在扩展 net.rim.device.api.ui.Screen (不是 MainScreen 或 Screen 的其他子项),那么您应该专门设置 DEFAULT_CLOSE 样式或在屏幕应按以下方式取下时实现类似的调用 close() 的方法API 文档:

public boolean onClose()

Indicates a close event has occurred.

The default implementation is activated by specifying DEFAULT_CLOSE. It will call onSavePrompt() if the screen is dirty, then call close() if successful.

Returns:
    True if the screen closes; otherwise, false.
Since:
    JDE 3.6.0

调用 System.exit(0) 应该会导致您的应用程序退出,但是在实现中可能会出现延迟,以允许线程退出和屏幕完全关闭。黑莓 GUI 应用程序退出的正常方式是当最后一个屏幕从显示堆栈中弹出时,这在调用 close() 时发生。

If you are extending net.rim.device.api.ui.Screen (not MainScreen or some other child of Screen) then you should ether specifically set DEFAULT_CLOSE style or implement something similar calling close() when the screen should be taken down per the API docs:

public boolean onClose()

Indicates a close event has occurred.

The default implementation is activated by specifying DEFAULT_CLOSE. It will call onSavePrompt() if the screen is dirty, then call close() if successful.

Returns:
    True if the screen closes; otherwise, false.
Since:
    JDE 3.6.0

Calling System.exit(0) should result in your app exiting however there may be hold offs in the implementation to allow threads to exit and screens to close cleanly. The normal way for a blackberry GUI application to exit is when the last screen is popped off the display stack, which happens when close() is called.

隱形的亼 2024-08-14 09:02:15

不要调用 System.exit(0); 调用 super.onClose(); 除非如下所示,您不会覆盖 MainScreen

Don't call System.exit(0); call super.onClose(); unless as he says below your not overridding MainScreen

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文