08-25-2008 12:14 PM
Hi,
Does anyone know how to make a phone call or sms from application using API?
Please help me on this.
Thanks,
DK.
Solved! Go to Solution.
08-25-2008 12:46 PM
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.
08-25-2008 02:17 PM
Hi javec,
Thank you so much for your help.
DK.
11-14-2008 11:43 AM
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!
11-21-2008 04:27 PM
06-12-2009 11:51 AM
07-07-2009 03:38 PM - last edited on 07-07-2009 03:56 PM
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());
}
}
}

01-30-2010 06:38 AM
I am using the Autocomplete Field (net.rim.device.api.ui.component.AutoCompleteField
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.
02-16-2010 03:27 PM
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!
02-16-2010 03:51 PM
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.