1 23 import javax.microedition.midlet.*; 24 import javax.microedition.lcdui.*; 25 import javax.microedition.io.*; 26 27 import com.scalagent.kjoram.*; 28 29 import java.io.*; 30 import java.util.*; 31 32 34 public class MsgListener implements MessageListener { 35 36 KConsumer kComsumer = null; 37 38 public MsgListener(KConsumer kComsumer) { 39 this.kComsumer = kComsumer; 40 } 41 42 public void onMessage(Message msg) 43 { 44 try { 45 if (msg instanceof TextMessage) { 46 kComsumer.addText("\nfrom topic: " + ((TextMessage) msg).getText()); 48 } 49 kComsumer.display.setCurrent(kComsumer.mainScreen); 50 } 51 catch (Exception exc) { 52 System.out.println("Exception in listener: " + exc); 53 } 54 } 55 } 56 | Popular Tags |