File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Russian Message Problem

 
Sahil Reddy
Ranch Hand
Posts: 145
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys,,,,

I am trying to send "Russian Message" as follows




I get "Null Pointer Exception ". However it is not the case with the normal message like

String message = "Java Programmer"

 
Nicholas Kellner
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sahil,

I've got exactly the same problem. A russian user reports that sending SMS in russia fails and I've tracked it down to

sms.sendTextMessage(GetPhoneNumber(phoneNumber), null, message, sentPI, deliveredPI);

throws a null exception???

The same SMS in english works fine.

Did you sort it out?

 
Sahil Reddy
Ranch Hand
Posts: 145
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nicholas .... problem is solved !!!

The problem was with the Russian Character..... Russian character takes 2 bytes and the number of bytes that could be sent through sms is only 160 in one time.
So the solution is to divide the message and send it iff it exceeds 160 bytes.
 
Nicholas Kellner
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for your reply

My code is like this:


Maybe it's wrong to test for > 160?
 
Sahil Reddy
Ranch Hand
Posts: 145
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Nicholas

Best thing is to use in both the cases and let android system decide whether to send multiple messages or only one. I have not checked with the same so please make sure by using the only above statement for both the cases.

Moreover

this line could be problematic as length for russian message could be 70 characters long but it is taking more than 160 bytes as "Russin Character" takes more than 1 byte for 1 character and is not like english character, so better approach would be to getBytes() and then check on it.

Thanks and Regards
 
Nicholas Kellner
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, thanks.

I got it working now with sendMultipartTextMessage. One might wonder why there is a sendTextMessage or why sendTextMessage doesn't take care of this.

Krgds,

Nicholas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic