BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 02-04-2009, 02:42 AM   #1 (permalink)
New Member
 
Join Date: Feb 2009
Model: Bold
PIN: N/A
Carrier: SkTelecom
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with SMS

Please Login to Remove!

When I used first sample source, It works well
But, Second source throws exception "_dc.send(d);" point
What wrong with this?


First Source
--------------------------------------------------------------------
import net.rim.device.api.system.*;
import javax.microedition.io.*;
import java.io.*;

public class SmsSample extends Application {
private static final int MAX_PHONE_NUMBER_LENGTH = 32;
// Members.
private String addr = "01029581234";
private String msg = "This is a test message.";
private DatagramConnection _dc = null;
private static String _openString = "sms://";

public static void main(String[] args) {

new SmsSample();
}

public SmsSample() {

try {
_dc = (DatagramConnection) Connector.open(_openString);
byte[] data = msg.getBytes();
Datagram d = _dc.newDatagram(_dc.getMaximumLength());
d.setAddress("//" + addr);
d.setData(data, 0, data.length);
_dc.send(d);
} catch (IOException e) {
}
System.exit(0);
}

}


Second source

--------------------------------------------------------------------

import java.io.IOException;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import javax.microedition.io.*;


public class SmsFinal extends UiApplication {
public static void main(String[] args) {
SmsFinal theApp = new SmsFinal();
theApp.enterEventDispatcher();
}

public SmsFinal() {
pushScreen(new SmsFinalScreen());
}

final class SmsFinalScreen extends MainScreen {

public SmsFinalScreen() {
super();
FieldChangeListener listener = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
String addr = "01029581234";
String msg = "This is a test message.";
DatagramConnection _dc = null;
try {
_dc = (DatagramConnection) Connector.open("sms://");
byte[] data = msg.getBytes();
Datagram d = _dc.newDatagram(_dc.getMaximumLength());
d.setAddress("//" + addr);
d.setData(data, 0, data.length);
_dc.send(d); //Exception Point
} catch (IOException e) {
}
}
};
ButtonField buttonField = new ButtonField("Button");
buttonField.setChangeListener(listener);
add(buttonField);
}
}
}

And how can I see the exception message on BlackBerry Device?
Thanks
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LOT OF 2 INTEL XEON SLACB CPU/MICROPROCESSORS E5310
$19.99
LOT OF 2 INTEL XEON SLACB CPU/MICROPROCESSORS E5310 pictureXeon x3430 with board and 6 gb pc3 memory Lot Q207
$65.0
Xeon x3430 with board and 6 gb  pc3 memory    Lot Q207 pictureIntel Server - Xeon X3230 - 8GB RAM - 2 - 1.5TB HDD
$40.0
Intel Server - Xeon X3230 - 8GB RAM - 2 - 1.5TB HDD pictureSUPERMICRO CSE-826 SERVER X9DRD-7LN4F-JBOD 2*INTEL XEON E5-2620 6-CORE 2GHz 98GB
$499.99
SUPERMICRO CSE-826 SERVER X9DRD-7LN4F-JBOD 2*INTEL XEON E5-2620 6-CORE 2GHz 98GB pictureHoneywell Xeon 1900 Barcode Scanner 1900HHD-0 w/ USB Cable
$39.98
Honeywell Xeon 1900 Barcode Scanner 1900HHD-0 w/ USB Cable picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.