*
The moose likes Android and the fly likes Russian Message Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Russian Message Problem" Watch "Russian Message Problem" New topic
Author

Russian Message Problem

Sahil Reddy
Ranch Hand

Joined: Jan 24, 2011
Posts: 145
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

Joined: Dec 15, 2011
Posts: 3
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

Joined: Jan 24, 2011
Posts: 145
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

Joined: Dec 15, 2011
Posts: 3
Hi, thanks for your reply

My code is like this:


Maybe it's wrong to test for > 160?
Sahil Reddy
Ranch Hand

Joined: Jan 24, 2011
Posts: 145
@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

Joined: Dec 15, 2011
Posts: 3
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
 
jQuery in Action, 2nd edition
 
subject: Russian Message Problem
 
Similar Threads
how to handle fatal exception,activity not found?
list view problem
How to retrieve string from EditText?
need to find distance between given two cities
Android CustomListView getView() getting nullpointerexception