Troubleshooting guide
221
15: Creating push applications
}
}
// Constructor.
public HTTPPushDemo() {
_mainScreen = new HTTPMainScreen();
_mainScreen.setTitle(new LabelField(_resources.getString(HTTPPUSHDEMO_TITLE),
LabelField.USE_ALL_WIDTH));
_infoField = new RichTextField();
_mainScreen.add(_infoField);
_mainScreen.add(new SeparatorField());
_imageField = new RichTextField();
_mainScreen.add(_imageField);
_listeningThread = new ListeningThread();
_listeningThread.start();
_infoField.setText(_resources.getString(HTTPPUSHDEMO_LISTENTHREADSTARTED));
pushScreen(_mainScreen);
}
private void updateMessage(final byte[] data) {
Application.getApplication().invokeLater(new Runnable() {
public void run() {
//query the user to load the received message
String[] choices = {_resources.getString(HTTPPUSHDEMO_DIALOG_OK),
_resources.getString (HTTPPUSHDEMO_DIALOG_CANCEL)};
if ( 0 != Dialog.ask(_resources.getString(HTTPPUSHDEMO_QUERYFORRENDER), choices, 0)
)
{
return;
}
_infoField.setText(_resources.getString(HTTPPUSHDEMO_IMAGEINFO) + data.length);
try {
_imageField.setText(new String(data));
}
catch (Exception e) {
Dialog.inform(e.toString());
System.err.println(e.toString());
}
}
});
}
}