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
duksunkim
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified
Accepted Solution

make a phone call from application

Hi,

 

Does anyone know how to make a phone call or sms from application using API?

Please help me on this.

 

Thanks,

DK.

Please use plain text.
Developer
javec
Posts: 445
Registered: ‎07-15-2008
My Device: Not Specified

Re: make a phone call from application

Call:

 

public void makeCall(String data){ String phoneNumber = data; if ( phoneNumber.length() == 0 ){ System.out.println("Error, not a phone number"); } else { PhoneArguments call = new PhoneArguments (PhoneArguments.ARG_CALL,phoneNumber); Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, call); } }

 

 

SMS to Number:

 

public void makeSMS(String number){ try{ MessageConnection mc = (MessageConnection)Connector.open("sms://"); TextMessage textMessage = (TextMessage)mc.newMessage(MessageConnection.TEXT_MESSAGE); textMessage.setAddress("sms://" + number); Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(textMessage)); } catch (IOException e){ Dialog.alert(e.getMessage()); } }

 

 

Note that you still have to import the APIs for Invoke and Messaging and so. 

 

 

 

If your question was answered, please accept it as a sollution and / or give Kudos ;-)
______________________________
Use the Search Field first! Maybe the question you want to ask already exists!
Please use plain text.
Developer
duksunkim
Posts: 141
Registered: ‎08-06-2008
My Device: Not Specified

Re: make a phone call from application

Hi javec,

 

Thank you so much for your help.

 

DK.

Please use plain text.
New Developer
amiejoye
Posts: 10
Registered: ‎10-16-2008
My Device: Not Specified

Re: make a phone call from application

This is great!  It's exactly the kind of code I was looking for.  However, I'm new to Java and developing for blackberries.  Would you be able to tell me how to call this code?  I am trying to call a phone number from an application that lists customers.  It would be similar to the Keyword Filter or Address Book search.  Thanks!

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: make a phone call from application

I recommend having a look at the smsdemo included with the BlackBerry JDE for a full example.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
txj78
Posts: 32
Registered: ‎05-19-2009
My Device: Not Specified

Re: make a phone call from application

Thanks for information!
Please use plain text.
Developer
ronenfe
Posts: 77
Registered: ‎06-03-2009
My Device: Not Specified

Re: make a phone call from application

[ Edited ]

There is an "jvm error: 104 uncaught: throwable" error in simulator after sending the sms and tapping the back button to go back to the application. please help.

 

App.java:

 



import net.rim.device.api.ui.UiApplication;


public class App extends UiApplication
{
Screen2 screen2;

public static void main(String[] args)
{
App app = new App();
app.enterEventDispatcher();
}
public App()
{
screen2 = new Screen2();
pushScreen(screen2);
}

}

 Screen2.java:

 

import java.io.IOException;

import javax.microedition.io.Connector;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;


import net.rim.blackberry.api.invoke.Invoke;
import net.rim.blackberry.api.invoke.MessageArguments;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;


final class Screen2 extends MainScreen
{


public Screen2()
{
super();
setTitle(new LabelField("Screen2"));
try
{
String number = "1234";
MessageConnection mc = (MessageConnection)Connector.open("sms://");
TextMessage textMessage = (TextMessage)mc.newMessage(MessageConnection.TEXT_MESSAGE);
textMessage.setAddress("sms://" + number);
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(textMessage));
}
catch (IOException e)
{
Dialog.alert(e.getMessage());
}
}
}

 

 

 

 

 

 

Message Edited by ronenfe on 07-07-2009 03:47 PM
Message Edited by ronenfe on 07-07-2009 03:54 PM
Message Edited by ronenfe on 07-07-2009 03:56 PM
Please use plain text.
New Developer
taqitaha
Posts: 10
Registered: ‎01-28-2010
My Device: --

Re: make a phone call from application

I am using the Autocomplete Field (net.rim.device.api.ui.component.AutoCompleteField) and retrieving contacts information from the address book

how to i display it like it gets displayed in the Blackberry phone from find contacts and then call the user like you posted here.

 

 

Please use plain text.
Developer
jsdyer
Posts: 53
Registered: ‎10-02-2009
My Device: BlackBerry Tour 9630
My Carrier: Verizon

Re: make a phone call from application

I also can't figure out how to make phone numbers come up so that you can call them directly.  If you go to an email or a calendar invite and their is a phone number in it, you can go to the menu and call that number when its selected.  You see the phone number in the menu and everything.

 

How do you do this??

 

Thanks in advance!

Please use plain text.
Developer
ronenfe
Posts: 77
Registered: ‎06-03-2009
My Device: Not Specified

Re: make a phone call from application

I think what you need is :

 

public class ActiveRichTextField extends RichTextField implements CookieProvider

 

Field that uses a supplied set of string patterns to scan through a simple text string and pick out "active" regions.

These active regions are highlighted with underlining and will supply additional menu verbs if the user clicks on them.

Please use plain text.