BlackBerry application can listen to the status of incoming and outgoing phone calls. To do this our application must implement the PhoneListener interface (net.rim.blackberry.api.phone.PhoneListener) or AbstractPhoneListener class (net.rim.blackberry.api.phone.AbstractPhoneListener). The following code sample illustrates the implementation of the PhoneListener interface to block incoming call. EventInjector class is used to inject events into the system. This element is only accessible by signed applications. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Here is a sample code demonstrate, to reject the call that comes from all number. You can also customize as per your requirement by just putting some set of conditions with phone number.
import net.rim.blackberry.api.phone.Phone; import net.rim.blackberry.api.phone.PhoneCall; import net.rim.blackberry.api.phone.PhoneListener; import net.rim.device.api.system.Application; import net.rim.device.api.system.EventInjector; import net.rim.device.api.system.EventInjector.KeyCodeEvent; import net.rim.device.api.ui.Keypad; public class CallReject extends Application implements PhoneListener { public CallReject() { Phone.addPhoneListener(this); } public static void main(String[] args) { new CallReject().enterEventDispatcher(); } public void callAdded(int callId) { //put your condition here for blocking call } public void callAnswered(int callId) { } public void callConferenceCallEstablished(int callId) { } public void callConnected(int callId) {} public void callDirectConnectConnected(int callId) { } public void callDirectConnectDisconnected(int callId) { } public void callDisconnected(int callId) {} public void callEndedByUser(int callId) {} }