I have written the following code where on listening to a key event, the following code is executed.
Code:
public boolean keyRepeat(int keycode, int time) {
try {
count = 0;
UiApplication.getApplication().removeKeyListener(this);
System.out.println("Sending SMS .... ");
MessageConnection conn = null;
TextMessage text = null;
String message = "Hello ... this is a test msg";
conn = (MessageConnection) Connector.open("sms://" + phNumbers);
text = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
text.setPayloadText(message);
conn.send(text);
conn.close();
} catch (Exception ex) {
System.out.println("Excemtion: " + ex.toString());
}
}
But i get following error @ conn.send(text):
java.lang.RuntimeException: blocking operation not permitted on event dispatch thread.
Any idea why this is happening.