send sms from background thread in blackberry using j2me

Posted by SWATI on Stack Overflow See other posts from Stack Overflow or by SWATI
Published on 2010-06-16T07:13:31Z Indexed on 2010/06/16 9:52 UTC
Read the original article Hit count: 1010

Filed under:
|

hey i made a lot of search and found some similar types of code. I tried for gsm

method 1 gives IllegalArgumentException

try
{
MessageConnection _mc = (MessageConnection)Connector.open("sms://");
TextMessage tm = (TextMessage) _mc.newMessage(MessageConnection.TEXT_MESSAGE);
tm.setPayloadText(smsText);
tm.setAddress("965xxxxxxx");
_mc.send(tm);
_mc.close();
}catch(exception e){}

method 2: gives java.lang.error exception

  try
    {
    MessageConnection _mc = (MessageConnection)Connector.open("sms://");
    TextMessage tm = (TextMessage) _mc.newMessage(MessageConnection.TEXT_MESSAGE,
"//9790XXXXXX");
    tm.setPayloadText(text);
    _mc.send(tm);
    _mc.close();
        }catch(Exception e){}

I think the problem is with address i also tried : but no success +91965xxxxxxx , 0091965xxxxxxx , 0965xxxxxxx

How my application works----

i have created 2 applications--

1) Application 1 is a background app that is a System module as well as 
    startup application.
2) Another is a uiapplication

the background app runs in background.If there comes an incoming call then a flag value is set in persistent object and after checking that value as true the sms is send to that no from whom call is made.

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about storm