View Single Post
Old 10-28-2009, 02:35 PM   #1 (permalink)
New Member
Join Date: Sep 2009
Model: 8900
Carrier: Vodafone
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default IOException when using international access code (+) for sending SMS

Please Login to Remove!

I have the following code :
try {
  MessageConnection msgConn = (MessageConnection)"sms://" + _receiver + ":9204");
  Message msg = msgConn.newMessage(MessageConnection.BINARY_MESSAGE);
  BinaryMessage binMsg = (BinaryMessage) msg;
  String payload = "test";
  showMessage("Contact SMS sent.");
} catch (SecurityException se) {
  showMessage("SMS blocked by security settings. " + se.getMessage());
} catch (InterruptedIOException e) {
  showMessage("SMS delivery intrerrupted. " + e.getMessage());
} catch (IOException e) {
  showMessage("Error delivering SMS." + e.getMessage());
If _receiver contains a phone number without country code (eg : 0744333222) the message is sent .
If _receiver contains a phone number with country code and (+) for international access code like +40744333222 the message is not sent and IOException is raised.
If _receiver contains a phone number with country code and actual local international access code like 0040744333222 the message is sent again with no errors.

This is a very weird behaviour because people sometimes store numbers in full international format because they need them when roaming.

I thought about replacing + with 00, but this is not a general valid solution because some parts of the world use different international acces codes : 00 in Europe, 011 in Unites States and a lot more codes in Asia.

Is there a way to determine the network access code or automatically transform a phone number from the agenda to MSISDN format ?

Any other suggestions are welcome.

Thank you,
Offline   Reply With Quote