dcsimg
how to send SMS from J2ME application
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   dhiraj_chauhan
Posted On:   Friday, April 11, 2003 08:47 AM

Hi, I am trying to send sms from a MIDP but it a giving a error "NYI". Any clues how to solve that error or what is it about. Sniplet of code : private void sendSMS(){ MessageConnection conn = null; String url = "sms://+491757072004"; try { conn = (MessageConnection) Connector.open( url ); // do something with the connection sendText(conn, "hi there"); System.out.println("Message sent sucessfully"); } catch( Exception e ){ // handle errors System.out.println("message not sent " + e.getMessage()); e.printStackT   More>>

Hi,
I am trying to send sms from a MIDP but it a giving a error "NYI". Any clues how to solve that error or what is it about.
Sniplet of code :


private void sendSMS(){


MessageConnection conn = null;

String url = "sms://+491757072004";


try {


conn = (MessageConnection) Connector.open( url );

// do something with the connection

sendText(conn, "hi there");

System.out.println("Message sent sucessfully");

}


catch( Exception e ){

// handle errors

System.out.println("message not sent " + e.getMessage());

e.printStackTrace();

}
finally {

if( conn != null ){

try { conn.close(); } catch( Exception e ){}
}

}




}


private void sendText( MessageConnection conn, String text )

throws IOException, InterruptedIOException {

TextMessage msg = (TextMessage) conn.newMessage( conn.TEXT_MESSAGE );

msg.setPayloadText( text );

conn.send( msg );

}

   <<Less
About | Sitemap | Contact