2013-02-15 35 views
1

我正在使用asmack在我的應用程序中聊天。 運行以下代碼時出現錯誤。from.createForm()在使用asmack for android時產生錯誤

mXmppConnection=connectionToXmppServer(HOST, PORT, SERVICE, mUserName, mPassword);  

/*creating new chat room*/ 
MultiUserChat muc = new MultiUserChat(mXmppConnection, "[email protected]"); 

try { 

    /*to create chat room*/ 

    /*sending configration to server*/ 
     muc.join(mUserName); 
    Form form = muc.getConfigurationForm(); 
     Form answerForm = form.createAnswerForm(); 

     answerForm.setAnswer("muc#roomconfig_persistentroom", true); 

     muc.sendConfigurationForm(answerForm); 

    /*muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));*/ 

/* muc.join("jack");*/ 

    muc.sendMessage("i just joined the room"); 
    Log.i("room name", muc.getRoom()); 
    muc.addMessageListener(new PacketListener() { 
      @Override 
      public void processPacket(Packet packet) { 

       Message mess = (Message) packet; 
       Log.i("msg ",mess.getFrom() + ": " + mess.getBody()); 
      } 
     }); 


} catch (XMPPException e) { 

    Toast.makeText(getApplicationContext(), "test room failed", 
      Toast.LENGTH_SHORT).show(); 
} 

下面是錯誤我越來越

02-15 17:54:28.409: E/AndroidRuntime(24400): at java.lang.Thread.run(Thread.java:856) 
02-15 17:54:28.409: E/AndroidRuntime(24400): Caused by: java.lang.NullPointerException 
02-15 17:54:28.409: E/AndroidRuntime(24400): at com.example.groupchat.GroupChat$ConnectTOChatServer.doInBackground(GroupChat.java:174) 
02-15 17:54:28.409: E/AndroidRuntime(24400): at  com.example.groupchat.GroupChat$ConnectTOChatServer.doInBackground(GroupChat.java:1) 
02-15 17:54:28.409: E/AndroidRuntime(24400): at android.os.AsyncTask$2.call(AsyncTask.java:287) 
02-15 17:54:28.409: E/AndroidRuntime(24400): at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
+0

發生了什麼@CybaseChat.java:174?這是NPE拋出 – Flow 2013-02-15 17:17:05

+0

檢查此問題和答案,它將解決您的問題..http://stackoverflow.com/a/15787396/964741 – 2013-04-12 06:37:30

回答

相關問題