黑莓:无法修改 PhoneScreen

发布于 2025-01-08 19:24:51 字数 810 浏览 3 评论 0原文

我试图在每次拨出电话时在 PhoneScreen 上显示自定义图像和文本。我已经实现了 PhoneListener 接口并尝试了以下代码:

    PhoneScreen phoneScreen = new PhoneScreen(callId, app);
    phoneScreen.deleteAll(); // Empty the default PhoneScreen

    phoneScreen.setScreenBackground(0xFF0000);
    phoneScreen.setScreenBackground(0x00FF00);

    BitmapField bmf = new BitmapField(Bitmap.getBitmapResource("img.png"), Field.FIELD_TOP);
    LabelField labelField = new LabelField("Location");

    PhoneScreenVerticalManager psvm = new PhoneScreenVerticalManager();
    psvm.add(bmf);
    psvm.add(labelField);

    phoneScreen.add(psvm);
    phoneScreen.sendDataToScreen();

由于我尝试清空默认 PhoneScreen 的第二行,程序崩溃了。如果我注释掉该行,那么它将在 PhoneScreen 的底部显示图像,同时保留默认 PhoneScreen 中的所有其他字段。

我想删除默认 PhoneScreen 中的所有字段并添加自定义字段。预先感谢您的任何帮助!

I am trying to display custom image and text on PhoneScreen every time an outgoing call happens. I have implemented the PhoneListener interface and tried the following code:

    PhoneScreen phoneScreen = new PhoneScreen(callId, app);
    phoneScreen.deleteAll(); // Empty the default PhoneScreen

    phoneScreen.setScreenBackground(0xFF0000);
    phoneScreen.setScreenBackground(0x00FF00);

    BitmapField bmf = new BitmapField(Bitmap.getBitmapResource("img.png"), Field.FIELD_TOP);
    LabelField labelField = new LabelField("Location");

    PhoneScreenVerticalManager psvm = new PhoneScreenVerticalManager();
    psvm.add(bmf);
    psvm.add(labelField);

    phoneScreen.add(psvm);
    phoneScreen.sendDataToScreen();

The program crashes because of second line where I try to empty the default PhoneScreen. If I comment that line out then it displays the image at the bottom portion of the PhoneScreen while retaining every other fields from the default PhoneScreen.

I want to delete all the fields from default PhoneScreen and add custom fields. Thanks in advance for any help!

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

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

发布评论

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

评论(2

巾帼英雄 2025-01-15 19:24:51

一个黑客解决方案:在 PhoneListener 实现中,获取当前活动屏幕并将其用作 PhoneScreen。然后清空屏幕,以便您可以添加自己的字段。

像这样的东西:

    Screen phoneScreen = UiApplication.getUiApplication().getActiveScreen();
    phoneScreen.deleteAll();
    // Add your own fields to phoneScreen now

A hackish solution: Inside the PhoneListener implementation, get the currently active screen and use it as the PhoneScreen. And then empty the screen so that you can add your own fields.

Something like:

    Screen phoneScreen = UiApplication.getUiApplication().getActiveScreen();
    phoneScreen.deleteAll();
    // Add your own fields to phoneScreen now
墨落画卷 2025-01-15 19:24:51

删除对 phoneScreen.deleteAll() 的调用。

当执行上述行时,会引发 RuntimeException 异常,并显示“Manager isempty”。信息。

如果您使用的是 BlackBerry API 6.0 及更高版本,请考虑使用 ScreenModel#getPhoneScreen() 而不是 PhoneScreen(),因为后者已被弃用。请查看此开发指南了解更多信息。

编辑:恕我直言,不可能完全自定义 PhoneScreen 和默认的“字段”(不确定它们是否是偶数字段),例如图片、电话号码等,将始终出现在以编程方式添加的字段之前。

Remove the call to phoneScreen.deleteAll().

When the aforementioned line is executed, a RuntimeException exception is thrown with "Manager is empty." message.

If you are using BlackBerry API version 6.0 and up consider using ScreenModel#getPhoneScreen() instead of PhoneScreen() as the later is deprecated. Check this development guide for more information.

Edit: IMHO it is not possible to completely customize the PhoneScreen and the default "fields" (not sure that they are even fields) such as picture, phone number and etc, will always appear before the fields that were added programmatically.

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