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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 13
Registered: ‎04-22-2010
My Device: Blackberry Bold
My Carrier: AT&T
Accepted Solution

Phone Screen Action

So I have the following code provided by RIM ready to use in my application:

package com.rim.samples.device.phonescreendemo;

import net.rim.blackberry.api.phone.AbstractPhoneListener;
import net.rim.blackberry.api.phone.Phone;
import net.rim.blackberry.api.phone.PhoneCall;
import net.rim.blackberry.api.phone.phonegui.PhoneScreen;
import net.rim.blackberry.api.phone.phonegui.PhoneScreenVerticalManager;
import net.rim.blackberry.api.phone.phonegui.PhoneScreenHorizontalManager;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

 * This class listens for incoming calls.  When either of the callIncoming(),
 * callWaiting(), or callInitiated() callbacks have been invoked, this sample
 * application will send data to the incoming and active call screens. 
public final class PhoneScreenAction extends AbstractPhoneListener
    private Application _app;
     * Constructs a new PhoneScreenAction object
     * @param app A reference to the Application instance
    public PhoneScreenAction(Application app)
        _app = app;                     
     * Creates various managers and fields contained within a PhoneScreen object
     * which then sends its data to the Phone application's foreground screen.
     * @param callid Id of an incoming call
    private void sendPhoneScreenData(int callid)
        PhoneCall phoneCall = Phone.getCall(callid);
        if(phoneCall != null)
            String phoneNumber = phoneCall.getPhoneNumber();
                // Initialize PhoneScreen 
                PhoneScreen phoneScreen = new PhoneScreen(callid, _app);
                // Create a PhoneScreenHorizontalManager
                PhoneScreenHorizontalManager phoneScreenHorizontalManager1 = new PhoneScreenHorizontalManager();
                // Create a Bitmap
                Bitmap bitmap = Bitmap.getBitmapResource("logo.jpg");
                // Get phone screen dimensions
                XYRect incomingLandscape = PhoneScreen.getDimensions(PhoneScreen.LANDSCAPE, PhoneScreen.INCOMING);
                XYRect activeLandscape = PhoneScreen.getDimensions(PhoneScreen.LANDSCAPE, PhoneScreen.ACTIVECALL);
                XYRect incomingPortrait = PhoneScreen.getDimensions(PhoneScreen.PORTRAIT, PhoneScreen.INCOMING);
                XYRect activePortrait = PhoneScreen.getDimensions(PhoneScreen.PORTRAIT, PhoneScreen.ACTIVECALL);              
                // Get phone screen widths                
                int incomingLandscapeWidth = 0;
                if(incomingLandscape != null)
                    incomingLandscapeWidth = incomingLandscape.width; 
                int activeLandscapeWidth = 0;
                if(activeLandscape != null)
                   activeLandscapeWidth =  activeLandscape.width;
                int incomingPortraitWidth = incomingPortrait.width;                
                int activePortraitWidth = activePortrait.width;             
                // Calculate minimum width for active and incoming phone screens in portrait or landscape orientation 
                int minWidth =  Math.min(incomingPortraitWidth, activePortraitWidth);
                if(activeLandscapeWidth > 0)
                   minWidth =  Math.min(activeLandscapeWidth, minWidth);
                if(incomingLandscapeWidth > 0)
                   minWidth = Math.min(incomingLandscapeWidth, minWidth); 
                int bitmapWidth = bitmap.getWidth();
                int bitmapHeight = bitmap.getHeight();
                // Resize the bitmap if its width exceeds the minimum width                                   
                if(bitmapWidth > minWidth)
                    Bitmap bitmapScaled = new Bitmap(minWidth, bitmapHeight);
                    // Scale the original Bitmap into the new Bitmap using
                    // a Lanczos filter.            
                    bitmap.scaleInto(bitmapScaled, Bitmap.FILTER_LANCZOS);
                    // Assign the bitmap and bitmapWidth references
                    bitmap = bitmapScaled;          
                    bitmapWidth = bitmap.getWidth();          
                // Calculate and set padding
                int displayWidth = Display.getWidth();                
                int padding = (displayWidth - bitmapWidth) / 2;                
                phoneScreenHorizontalManager1.setPadding(0, padding, 0 , padding);
                // Add the bitmap image to the PhoneScreenHorizontalManager
                // and add to the phone screen.
                // Create a PhoneScreenVerticalManager and add fields
                PhoneScreenVerticalManager phoneScreenVerticalManager = new PhoneScreenVerticalManager();                        
                phoneScreenVerticalManager.add(new LabelField("Adam McCombs/Junior"));
                phoneScreenVerticalManager.add(new LabelField("Coach Notes: Loves Biking"));               
                // Create a PhoneScreenHorizontalManager, set padding and
                // add the PhoneScreenVerticalManager.
                PhoneScreenHorizontalManager phoneScreenHorizontalManager2 = new PhoneScreenHorizontalManager();
                phoneScreenHorizontalManager2.setPadding(0, 60, 0, 60);
                // Add fields to PhoneScreen and display

     * @see AbstractPhoneListener#callWaiting(int)
    public void callWaiting(int callid)
     * @see AbstractPhoneListener#callInitiated(int)
    public void callInitiated(int callid) 

     * @see AbstractPhoneListener#callIncoming(int)
    public void callIncoming(int callid)


Basically it brings up an action screen when a certain number calls. My question is can I perform a loop to take the variable "phoneNumber" and cross check it with numbers I have stored in a database using an XML request and choose to display the phone action if a boolean returns true?? If so how would I implement that using this code?

Posts: 74
Registered: ‎01-03-2010
My Device: Not Specified

Re: Phone Screen Action

one way.... 1. first........u should implement phoneListener where in appropriate call handing method you check the number with your database and mark a flag .....2. then show you screen in phonescreen depending on your flag ................ another way................ do you checking in phonescreen just before showing the popup, show it based on outcone of checking .......................................................................................................................... ...............................................mark 'solved' + kudoes