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
Developer
Posts: 293
Registered: ‎02-25-2009
My Device: Not Specified

Re: Reject a call Programatically

May be you are right..i cheked it out on OS 4.5 ...i didnt check it out on OS 5.0

New Developer
Posts: 27
Registered: ‎12-31-2008
My Device: Not Specified

Re: Reject a call Programatically

Hello,

 

I just wanted to let you know that I tested the notifications manager demo (notificationsdemo) on several simulators. The problem I was having with the IllegalArgumentException seems to be a problem with the 9700 v5.0.0.228 simulator. I changed to 9700 v5.0.0.400 and it works as expected.

 

Note that any use of triggerImmediateEvent with with the 9700 v5.0.0.228 simulator will cause the same IllegalArgumentException to be thrown.

 

Thanks for all the input.

New Developer
Posts: 27
Registered: ‎12-31-2008
My Device: Not Specified

Re: Reject a call Programatically

This works fine on OS v5.0. I recently tried v4.5 and v4.6 without success. The problem is that I cannot override the default ring even when using NotificationsConstants.FORCED. The default ring is mixed with the custom ring. What is wrong with this code? Thanks for any help.

 

 

In the phone's callIncoming method I check the phone number and then trigger the notification using:

NotificationsManager.triggerImmediateEvent(kSourceId, 0, this, null);

I register notifications in my application constructor using:

 

    NotificationsManager.registerSource(kSourceId, new Object() {
      public String toString() {
        return "Custom Profile";
      }
    }, NotificationsConstants.FORCED);
    NotificationsManager.registerConsequence(CallConsequence.ID, new CallConsequence());

 

 

Here is my consequence class:

 

public class CallConsequence implements Consequence {
  static final long ID = 0x187e0e325af4fffL;
  private static final Configuration CONFIG = new Configuration();

  public void startNotification(long consequenceID, long sourceID,
      long eventID, Object configuration, Object context) {

 

    // Note this tune is the same as the demo (definition omitted for clarity).
    Alert.startAudio( TUNE, VOLUME );
  }

  public void stopNotification(long consequenceID, long sourceID, long eventID,
      Object configuration, Object context) {}

  public Object newConfiguration(long consequenceID, long sourceID,
      byte profileIndex, int level, Object context) {
    return CONFIG;
  }

  private static final class Configuration implements SyncObject, Persistable {
    public int getUID() {
      return 0;
    }
  }
}

Contributor
Posts: 12
Registered: ‎03-26-2010
My Device: 8310
My Carrier: Etisalat

Re: Reject a call Programatically

Hello

 

Did you manage to play your rightone alone on 4.5?

 

Best Regards

 

Mahammad

 

New Developer
Posts: 27
Registered: ‎12-31-2008
My Device: Not Specified

Re: Reject a call Programatically

I have not been able to make it work in v4.5 or v4.6. I'm still looking for help.

Regular Contributor
Posts: 67
Registered: ‎09-30-2009
My Device: Not Specified

Re: Reject a call Programatically

I have the same problem for 4.5 and 4.6 simulators. This works in 4.7 simulator. However on the real device (BB 9500 - 4.7.0.78) the injected ringtone stops after 1-2 second and the phone ringtone starts to play.

Regular Contributor
Posts: 67
Registered: ‎09-30-2009
My Device: Not Specified

Re: Reject a call Programatically

[ Edited ]

The following solution has worked for my 4.5/4.6 simulators and 8800 device:

register a consequence object and put the ringtone path to the context hash table to key 6476586477082074028 in the startNotification method.

 

For 4.7 simulator and 9500 device we had to implement a different solution.

Contributor
Posts: 19
Registered: ‎01-05-2012
My Device: developer
My Carrier: developer

Re: Reject a call Programatically

hey amardeep,

i am new to blackberry and i was trying a call block  using the given key injection method....the short "beep" issue was terminated by using the Notification API as per as your solution....but the problem i  am facing is that this method is blocking all the calls and not obly the desired one Smiley Sad (the one which i have hard-coded in the following part)....
Please help with issue....struggling with it from last 3 days.

 

this a library app which registers the source say block....

 

public class Block{
	

	public static final long ID_1 = 0xdc5bf2f81374095L;
	public static final Object event = new Object() {
	public String toString() { return "Block"; }
	};
	public static void libMain(String[] args) {
	NotificationsManager.registerSource(ID_1, event,NotificationsConstants.FORCED);
	}
	
}

 and this is the call listener implementation which is made in another application say "blocker" .....

 

public class CallListener extends AbstractPhoneListener  {
	public static final long NOTIFICATIONS_ID_1 = 0xdc5bf2f81374095L;

	  public CallListener() {
		  Phone.addPhoneListener(this);
	}
	public void callIncoming(int callId) {  
		
        final PhoneCall call = Phone.getCall(callId);  
        final String number = call.getDisplayPhoneNumber();  
        System.out.println(number); 
        UiApplication.getUiApplication().suspendPainting(true);
       
        NotificationsManager.registerSource(NOTIFICATIONS_ID_1, 
                new Object()
                {
                    public String toString()
                    {
                        return "Profile 1";
                    }
                }
                ,NotificationsConstants.FORCED);
        
        NotificationsManager.registerConsequence(ConsequenceImpl.ID, new ConsequenceImpl());
       
  
    }  
	
	
	private static final class ConsequenceImpl implements Consequence {
		  public static final long ID = 0xbd2350c0dfda2a51L;

		public Object newConfiguration(long consequenceID, long sourceID,
				byte profileIndex, int level, Object context) {
			  System.out.println("in newconfiguration method()");
	            return new Object();
			
		}

		public void startNotification(long consequenceID, long sourceID,
				long eventID, Object configuration, Object context) {
			 EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END, 0, 100);  
		        EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END, 0, 100);  
		  
		      
		        EventInjector.invokeEvent(pressEndKey);  
		        EventInjector.invokeEvent(releaseEndKey);  
		        UiApplication.getUiApplication().suspendPainting(false);
			
		}

		public void stopNotification(long consequenceID, long sourceID,
				long eventID, Object configuration, Object context) {
			// TODO Auto-generated method stub
		}
	
	
}
}

 

 Please help ....

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Reject a call Programatically

please create an own thread for your question. you can reference this or other relevant threads there.
many users don't check solved threads so you'll get better assistance there.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 19
Registered: ‎01-05-2012
My Device: developer
My Carrier: developer

Re: Reject a call Programatically

hey simon,

i do agree your point regarding less people reading solved threads but i m afraid i would be duplicating threads since my query was related to the solution given here ...