• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Russian Message Problem

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic