开发者

Blackberry - setPayloadText doesn't work

I am trying to use the TexTMessage interface to prepare a SMS before invoking invokeApplication in order to open the SMS application with a prefilled message. T开发者_高级运维he address (phone number) works well (it's prefilled) but the message body doesn't. Indeed it seems that the setPlayloadText method has no effect.

Here is my code

messConn = (MessageConnection)Connector.open("sms://");
TextMessage sMess=(TextMessage)messConn.newMessage(MessageConnection.TEXT_MESSAGE);
sMess.setAddress("sms://123456789");
sMess.setPayloadText(new String("ahah")); //doesn't seem to work
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(sMess));

Thanks for your help.

Vincent


There is a bug that prevents the body of the text from being populated in certain OS versions. You can get around it by storing the contents of the message to the clipboard, and then injecting a paste operation after waiting a second or so for the SMS app to come up. A little dodgy, but it's about the only thing you can do in that situtation.

Alternatively, you can create your own send-text screen that does this for the user. You can take a look at http://supportforums.blackberry.com/t5/Java-Development/Different-ways-to-send-SMS-messages/ta-p/445070 which gives instruction on how to programmatically send the message. Note that if you do this method, you should use both, with one being a fallback method if the first fails.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜