开发者

SMack API in java

开发者 https://www.devze.com 2022-12-12 11:10 出处:网络
public void processMessage(Chat chat, Message me开发者_运维技巧ssage) { if (message.getType() == Message.Type.chat)
public void processMessage(Chat chat, Message me开发者_运维技巧ssage) {
        if (message.getType() == Message.Type.chat)
            System.out.println(chat.getParticipant() + " says: "+ message.getBody());
      **processmsg** = message.getBody();
        System.out.println("Message from Friend -----:"+**processmsg**);

    }

Hi.how to use this processmsg String in another method.if i use outside this method i get null value. plz reply soon


Store processmsg as an instance variable in the class that contains processMessage

class Foo {
   private String processmsg;

   public void processMessage(Chat char, Message message) {
      processmsg = message.getBody();
   } 

   public void bar() {
      // do whatever you want
   }
}

Obviously you'll need to check that it's been assigned and so on before you use it (e.g. you couldn't use bar before processMessage), but you get the idea!

0

精彩评论

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