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
Trusted Contributor
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom

ButtonField Send SMS

Hi All

 

How can I make a buttonField send an sms once it has been "Clicked" on?

 

Please help , i Am new to the blackberry development.\

 

 

Thank you

Developer
Posts: 78
Registered: ‎05-17-2012
My Device: 9900 - OS 7.0 Torch device
My Carrier: Reliance

Re: ButtonField Send SMS

Hi, You have to register with listener like FieldChangelister/FocusChangeListener. Try to write like below.

ButtonField bf = new ButtonField("ButtonName");
bf.setChangeListener (new FieldChangeListener() {

public void fieldChanged(Field field, int context) {
// TODO Auto-generated method stub

}
});

inside fieldChanged method, you can write your action event.
Developer
Posts: 78
Registered: ‎05-17-2012
My Device: 9900 - OS 7.0 Torch device
My Carrier: Reliance

Re: ButtonField Send SMS

As action event you can write the below:
Message m = new Message();
Address a;
try {
a = new Address("", "");
Address[] addresses = {a};
m.addRecipients(Message.RecipientType.TO, addresses);
m.setContent("");
m.setSubject("");

} catch (Exception e) {

e.printStackTrace();
}
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(m));

This can be used to activate the message service of device
Highlighted
Trusted Contributor
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom

Re: ButtonField Send SMS

Hi there 

 

Thank you for the response but when I do so, there are errors that pop up.