2012-02-08 3 views
1

私のアプリケーションでは、私はjavaでコードを実行すると、 LO-ジンが成功したその時点でのプロジェクトが、それは私に404アンドロイドでAsmackを使用しているときにエラーが発生しました

をエラーを与えているノードにアクセスしている間、私は私を助けてpath.PleaseビルドにAsmack jarファイルを追加した...私はこだわっている...

public class ChatApplicationActivity extends Activity { 
    /** Called when the activity is first created. */ 
    static XMPPConnection connection; 
    TextView textView; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     textView=(TextView)findViewById(R.id.textView); 

     try { 
      ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new VCardProvider()); 
      ConnectionConfiguration cc = new ConnectionConfiguration("192.168.1.113", 5222, "192.168.1.113"); 
      connection = new XMPPConnection(cc); 
      connection.connect(); 
      SASLAuthentication.supportSASLMechanism("PLAIN", 0); 
      connection.login("test","test"); 
      Log.i("debug", "login success"); 


    //  MySmackClient client=new MySmackClient(); 
    //  client.login("test1","test1"); 

      //client.displayBuddyList(); 

     // CreateNode node = new CreateNode(connection); 
     subNode("[email protected]","testNode5"); 
     // String talkTo = br.readLine(); 

      System.out.println("-----"); 
     // System.out.println("All messages will be sent to " + talkTo); 
      System.out.println("Enter your message in the console:"); 
      System.out.println("-----\n"); 
    } catch (XMPPException e) { 

     e.printStackTrace(); 
    } 
    } 


    public void subNode(String JID,String nodeName) 
    { 


    PubSubManager mgr = new PubSubManager(connection); 
    // String pubSubAddress = "pubsub." + connection.getServiceName(); 
    // PubSubManager manager = new PubSubManager(connection, pubSubAddress); 
     try { 
      // Get the node 
     // Node eventNode = manager.getNode("testNode5"); //i always get error here 

      LeafNode node = (LeafNode)mgr.getNode(nodeName); 

     node.addItemEventListener(new ItemEventCoordinator()); 

     node.subscribe(JID); 
     } catch (XMPPException e) { 

      e.printStackTrace(); 
     } 
    } 

    class ItemEventCoordinator implements ItemEventListener 
    { 
     int track =0; 
     public void handlePublishedItems(ItemPublishEvent items) 
     { 
      System.out.println("Got Publish:"+track); 
      PayloadItem<SimplePayload> item = (PayloadItem<SimplePayload>) items.getItems().get(0); 

      SimplePayload payload = item.getPayload(); 

      String payloadData = payload.toXML(); 
      System.out.println(payloadData); 

     } 
    } 
} 
+0

解決策を見つけましたか? – Hunt

+0

関連する質問と回答:http://stackoverflow.com/a/10881849/842697 –

答えて

0

どのバージョンのSmackを使用していますか?私はasmackが維持されているとは思わないので、おそらくSmackと同期していません。スマックは、そののpubsubアドレスをデフォルトに変更されました

String pubSubAddress = "pubsub." + connection.getServiceName(); 
PubSubManager manager = new PubSubManager(connection, pubSubAddress); 

1つの提案は、あなたがコメントアウトしている行を

PubSubManager mgr = new PubSubManager(connection); 

を変更するだろう、asmackはおそらくその変更はありません。より明示的なコンストラクタを使用すると、両方の環境で一貫しています。

+0

aSmackの代替案については、この質問もご覧くださいhttp://stackoverflow.com/questions/4769020/android-and-xmpp-currently-利用可能なソリューション – Flow

関連する問題