Create a new populated text message

Use the API items in the javax.wireless.messaging package (JSR 120).
  1. Import the required classes and interfaces.
    import javax.microedition.io.Connector;
    import javax.wireless.messaging.MessageConnection;
    import javax.wireless.messaging.TextMessage;
    import net.rim.blackberry.api.invoke.Invoke;
    import net.rim.blackberry.api.invoke.MessageArguments;
    
  2. Create and populate a new TextMessage object.
    MessageConnection mc = (MessageConnection)Connector.open("sms://");
    TextMessage m = (TextMessage)mc.newMessage( MessageConnection.TEXT_MESSAGE );
    m.setAddress("sms://5558888");
    m.setPayloadText("An SMS message for you");
    
  3. Invoke Invoke.invokeApplication() with the following parameters:
    • APP_TYPE_MESSAGES: a constant parameter
    • MessageArguments: a new MessageArguments object that uses the new TextMessage object.
    Invoke.invokeApplication( Invoke.APP_TYPE_MESSAGES, new MessageArguments(m) );

Was this information helpful? Send us your comments.