黑莓:无法修改 PhoneScreen
我试图在每次拨出电话时在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个黑客解决方案:在 PhoneListener 实现中,获取当前活动屏幕并将其用作 PhoneScreen。然后清空屏幕,以便您可以添加自己的字段。
像这样的东西:
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:
删除对
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 ofPhoneScreen()
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.