Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Contributor
Posts: 25
Registered: ‎04-16-2012
My Device: Blackberry Bold
My Carrier: no_carrier

I want to change the Incoming Call Screen but many times it shows only for few time and than it get remove automatically on simulator for Blackberry OS6

public static void phoneScreenForOS6(int callId,final String text2){
//#ifdef BlackBerrySDK6.0.0
ScreenModel screenModel = new ScreenModel(callId);
PhoneScreen phoneScreenIncomingPortrait = screenModel.getPhoneScreen(PhoneScreen.PORTRAIT, PhoneScreen.INCOMING);
PhoneScreen phoneScreenIncomingLandscape = screenModel.getPhoneScreen(PhoneScreen.LANDSCAPE, PhoneScreen.INCOMING);

// Create a PhoneScreenHorizontalManager
PhoneScreenHorizontalManager phoneScreenHorizontalManager1 = new PhoneScreenHorizontalManager();

// Create a Bitmap
Bitmap bitmap = Bitmap.getBitmapResource("xyz..png");

// Calculate and set padding
String text1 ="Abc";
phoneScreenHorizontalManager1.addImage(bitmap);
phoneScreenHorizontalManager1.add(new LabelField(text1,DrawStyle.VCENTER));

PhoneScreenHorizontalManager phoneScreenHorizontalManager2 = new PhoneScreenHorizontalManager();
phoneScreenHorizontalManager2.add(new LabelField(text2,DrawStyle.VCENTER));

if(screenModel.getCurrentOrientation()==PhoneScreen.PORTRAIT ){
// Center the PhoneScreenHorizontalManager. UI fields
// are centered in the PhoneScreen by default with the
// exception of PhoneScreenHorizontalManager.
XYRect xyRect = phoneScreenIncomingPortrait.getDimensions();
int padPoint1 = (xyRect.width - phoneScreenHorizontalManager1.getPreferredWidth()) / 2;
int padPoint2 = (xyRect.width - phoneScreenHorizontalManager2.getPreferredWidth()) / 2;
if (padPoint1 > 0) {
phoneScreenHorizontalManager1.setPadding(0, padPoint1, 0, padPoint1);
}
if (padPoint2 > 0) {
phoneScreenHorizontalManager2.setPadding(0, padPoint2, 0, padPoint2);
}
phoneScreenIncomingPortrait.add(phoneScreenHorizontalManager1);
phoneScreenIncomingPortrait.add(phoneScreenHorizontalManager2);
}
else if(screenModel.getCurrentOrientation()==PhoneScreen.LANDSCAPE ){
XYRect xyRect = phoneScreenIncomingLandscape.getDimensions();
int padPoint1 = (xyRect.width - phoneScreenHorizontalManager1.getPreferredWidth()) / 2;
int padPoint2 = (xyRect.width - phoneScreenHorizontalManager2.getPreferredWidth()) / 2;
if (padPoint1 > 0) {
phoneScreenHorizontalManager1.setPadding(0, padPoint1, 0, padPoint1);
}
if (padPoint2 > 0) {
phoneScreenHorizontalManager2.setPadding(0, padPoint2, 0, padPoint2);
}
phoneScreenIncomingLandscape.add(phoneScreenHorizontalManager1);
phoneScreenIncomingLandscape.add(phoneScreenHorizontalManager2);
}
screenModel.sendAllDataToScreen();
}