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
New Contributor
bb_sk
Posts: 3
Registered: ‎03-30-2010
My Device: 9000

calling USSD commands via BB api

 

http://supportforums.blackberry.com/t5/Java-Development/PHONE-USSD/m-p/192877

 

I am following the same way as suggested above.

 

it works and confirms with all success message too.

 

But at the same time on the back ground to my application screen, it gives an error message with "cannot connect to *004#12341234#". this prevents the device make any calls until you find out this message and close the window.     

 

i am using,      

 

String strNumber = "*004#12341234#"; //USSD cmd to set call forwarding     

PhoneArguments phoneArgs = new PhoneArguments (PhoneArguments.ARG_CALL, strNumber );      

Invoke.invokeApplication( Invoke.APP_TYPE_PHONE, phoneArgs );  

 

What am i doing wrong? Any suggessions or hints?!!!

 

 

Please use plain text.
Contributor
andy_hollywood
Posts: 12
Registered: ‎08-25-2011
My Device: Bold 9780

Re: calling USSD commands via BB api

[ Edited ]

This should work to enable and disable call forwarding for you.

 

<code>

//Enable Call Forwarding
Invoke.invokeApplication(Invoke.APP_TYPE_PHONE,new PhoneArguments(PhoneArguments.ARG_CALL,"**004*" +  destination  + "#");


//Clear call forwarding

Invoke.invokeApplication(Invoke.APP_TYPE_PHONE,new PhoneArguments(PhoneArguments.ARG_CALL,"**004*"));

</code>

 

looks like you don't have enough stars on your number to invoke the call forwarding.

 

Please use plain text.
Contributor
andy_hollywood
Posts: 12
Registered: ‎08-25-2011
My Device: Bold 9780

Re: calling USSD commands via BB api

Here is an implmentation of a USSD Command Invoker that I've written and been using. It was designed to execute them in a managed fashion (not to many at once). It seems to work for the most part, maybe some tinkering is needed with the timeings etc. for your specific environment etc..

 

 

USSD Command Executor
public class USSDCommandExecutor {

	private static Vector commands = new Vector();
	
	public static void callUSSD(USSDCommand command, boolean enable){
		USSDCommandExecutor.commands.addElement(new CommandToExecute(command, enable));
		Application.getApplication().invokeLater(new Runnable(){
			public void run() {
				execute();		
			}
		}, 100, false);
	}
	
	
	private static void execute(){
		if(!commands.isEmpty()){
			final CommandToExecute execute = (CommandToExecute)commands.elementAt(0);
			commands.removeElementAt(0);
			new Thread(new Runnable(){
				public void run() {
					try{
						Invoke.invokeApplication(
								Invoke.APP_TYPE_PHONE,
								new PhoneArguments(
									PhoneArguments.ARG_CALL,
									execute.getCommand().getCommand(execute.isEnable())
							)
						);	
					}catch(Throwable t){
						//do something... maybe  a callback or log even
					}
				}
			}).start();
			if(commands.isEmpty()){
				Application.getApplication().invokeLater(new Runnable(){
					public void run() {
						execute();		
					}
				}, 1000, false);
			}
		}
	}
	
	private static class CommandToExecute {
		private USSDCommand command;
		private boolean enable;
		
		protected CommandToExecute(USSDCommand command, boolean enable){
			this.command = command;
			this.enable = enable;
		}
		
		public USSDCommand getCommand() {
			return command;
		}
		
		public boolean isEnable() {
			return enable;
		}
	}
}
USSD Commands (Call Forwarding)
public class CallForwarding extends USSDCommand {

	private String ddi;

	public CallForwarding(String callForward) {
		super("##004#{0}#", "**004*");
		this.ddi = callForward;
	}

	public String[] getData() {
		return new String[]{this.ddi};
	}
}
USSD Commands (Call Waiting)
public class CallWaiting extends USSDCommand {

	public CallWaiting() {
		super("*43#", "#43#");
	}

	public String[] getData() {
		return new String[]{};
	}
}
Please use plain text.
Contributor
dsokhan
Posts: 36
Registered: ‎07-06-2010
My Device: Blackberry Playbook tablet

Re: calling USSD commands via BB api

Hi andy_hollywood,

 

Thank you for your sample sources, but I don't understand how can I intercept incoming response call from server. Well, I need to create an app that hides response callback from server on USSD request call. And also I need hide Calling Screen, but after deep research I understand that it can't be done((. 

 

Please can you tell me which direction to move, because I totaly lost:smileysad:


Please use plain text.
Contributor
andy_hollywood
Posts: 12
Registered: ‎08-25-2011
My Device: Bold 9780

Re: calling USSD commands via BB api

Do you mean you want to fire a USSD and then prevent the Dialog showing up to the user, AND use the response from the server to do something else?

Please use plain text.
Contributor
dsokhan
Posts: 36
Registered: ‎07-06-2010
My Device: Blackberry Playbook tablet

Re: calling USSD commands via BB api

User make a USSD phone call like "*146*"+"00"+number+"#" and than carrier make response call to the user, then he picks it up and talking. So I need to hide callback from server from the user. So he just make ussd call and then automaticaly connected to destination opponent.

Please use plain text.
Contributor
andy_hollywood
Posts: 12
Registered: ‎08-25-2011
My Device: Bold 9780

Re: calling USSD commands via BB api

That is all very tough to do using the RIM SDK, in fact from my experience impossible by using hte functions available to you in the SDK.

 

Think you need to be looking a few levels lower in terms of technology for your devices in order to achieve something seamless.

Please use plain text.
Contributor
dsokhan
Posts: 36
Registered: ‎07-06-2010
My Device: Blackberry Playbook tablet

Re: calling USSD commands via BB api

Thank you for reply, I will try to dig lower.

Please use plain text.
New Contributor
naveen_sg
Posts: 6
Registered: ‎11-20-2012
My Device: curve

Re: calling USSD commands via BB api

hi, sorry to post my question in between......

 

In my case, is ther a setting to disable shown the raw message sent from server to BB via USSD ? In BB OS 6/7, USSD message sent by server is shown first (unformatted raw message), upon pressing OK, message gets formated and displays properly...

 

How can i disable the raw message apperaing as pop up text first ?  any help will be greatly appreciated

Please use plain text.