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
vignaraj
Posts: 9
Registered: ‎05-18-2013
My Device: 9800

how to invoke multiple numbers into new message screen?

package mypackage;

import java.io.IOException;
import java.util.Vector;
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.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.container.MainScreen;

/**
* A class extending the MainScreen class, which provides default standard
* behavior for BlackBerry GUI applications.
*/
public final class MyScreen extends MainScreen
{
/**
* Creates a new MyScreen object
*/
BasicEditField messageText;
ButtonField send;
Vector vector;
String[] numbers= {"9952377565","9977868666","6757656544"};
public MyScreen()
{
// Set the displayed title of the screen
messageText= new BasicEditField("Enter Your Message : ", "");
send= new ButtonField();
send.setLabel("Click here to send");
send.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
// TODO Auto-generated method stub
MessageConnection mc = null;
try
{
mc = (MessageConnection)Connector.open("sms://");
TextMessage m = (TextMessage)mc.newMessage(MessageConnection.TEXT_MESSAGE );
for(int i=0;i<numbers.length;++i)
{
if(numbers[i]!= null)
{
m.setAddress("sms://"+numbers[i]);
m.setPayloadText(messageText.getText());
Invoke.invokeApplication( Invoke.APP_TYPE_MESSAGES, new MessageArguments(m));
}
}
// m.setAddress("sms://"+"98646464778");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
add(messageText);
add(send);
}
}

 

 

This is my code, to invoke the message text and user's numbers into message compose screen. I trying to invoke more numbers into  m.setAddress(numbers[i]); do. But i'm unable to do. please anyone help me to give the solutions. Thank you.

Please use plain text.