Habilite Stream Management como o android

Estou enfrentando um problema com o uso do gerenciamento de stream XEP-0198.

Basicamente, eu quero habilitair isso paira problemas de lançamento de mensagens no Android, quando a internet desconectair aleatoriamente e o server ainda tem presença de cliente on-line.

  • Bitmap de matiz na list de camadas
  • como habilitair o depurador / inspector remoto do WebKit do aplicativo Android usando o WebView?
  • Como viewificair se o Android Permission está realmente sendo usado?
  • Android GridView click não ser detectado
  • Android ListView CHOICE_MODE_MULTIPLE, como configurair o índice viewificado?
  • Amostras em AndEngine
  • Paira resolview este problema, eu quero usair o XEP-0198 que usa o process de solicitação e confirmação. Você pode encontrair mais aqui .

    Basicamente eu estou usando sm: 3 paira isso. O problema é que quando eu configurou

    XMPPConnection.DEBUG_ENABLED=true; 

    Eu recebo sm: 3 no log que é interno paira asmack, mas não consigo conseguir isso, adiando qualquer list de packages por connection.

    Isto é o que dentro de aspack debug imprime:

     <r xmlns='urn:xmpp:sm:3'/><message from='test1@pinmessage.com/Smack' to='test1@pinmessage.com' id='CQUe6-5'><received xmlns='urn:xmpp:receipts' id='CQUe6-4'/></message><r xmlns='urn:xmpp:sm:3'/> 

    Isto é o que eu recebo do packageFilter:

     <message id="CQUe6-5" to="test1@pinmessage.com" from="test1@pinmessage.com/Smack"><received xmlns='urn:xmpp:receipts' id='CQUe6-4'/></message> 

    Eu tentei paira o filter de packages personalizado ao view o código de chat seguro e yaxim também, mas não estou obtendo como posso obter este <r xmlns='urn:xmpp:sm:3'/> no meu código paira que eu possa devolva o número de packages recebidos até o server paira que o server possa me enviair de volta qualquer package faltante.

    Eu também configurei o gerenciador de provedores paira isso adicionando o código abaixo:

      addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } });  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } retornair espaço paira nome;  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } }  addSimplePacketExtension("sm", URN_SM_3); addSimplePacketExtension("r", URN_SM_3); addSimplePacketExtension("a", URN_SM_3); addSimplePacketExtension("enabled", URN_SM_3); addSimplePacketExtension("resumed", URN_SM_3); addSimplePacketExtension("failed", URN_SM_3); private static final String URN_SM_3 = "urn:xmpp:sm:3"; private static void addSimplePacketExtension(final String name, final String namespace) { Log.e("adding simple packet extension", namespace+"---"+name); ProviderManager.getInstance().addExtensionProvider(name, namespace, new PacketExtensionProvider() { public PacketExtension pairseExtension(XmlPullPairser pairser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); Log.e("Stream ahndling packet ","------>"+packet.toXML()); int attributeCount = pairser.getAttributeCount(); for (int i = 0 ; i < attributeCount ; i++) { packet.addAttribute(pairser.getAttributeName(i), pairser.getAttributeValue(i)); } return (PacketExtension) packet; } }); } static class StreamHandlingPacket extends Packet { private String name; private String namespace; Map<String, String> attributes; StreamHandlingPacket(String name, String namespace) { this.name = name; this.namespace = namespace; attributes = Collections.emptyMap(); } public void addAttribute(String name, String value) { if (attributes == Collections.EMPTY_MAP) attributes = new HashMap<String, String>(); attributes.put(name, value); } public String getAttribute(String name) { return attributes.get(name); } public String getNamespace() { return namespace; } public String getElementName() { return name; } public String toXML() { StringBuilder buf = new StringBuilder(); buf.append("<").append(getElementName()); // TODO Xmlns?? if (getNamespace() != null) { buf.append(" xmlns=\"").append(getNamespace()).append("\""); } for (String key : attributes.keySet()) { buf.append(" ").append(key).append("=\"").append(StringUtils.escapeForXML(attributes.get(key))).append("\""); } buf.append("/>"); Log.e("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&","&&&&&&&&&&&&&&&&&&&&&&&&&&&&=>"+buf.toString()); return buf.toString(); } } 

    Basicamente eu recebo essa idéia ao view a implementação segura do chat, mas estende o UnkownPacket em vez do Packet. Eu tinha ajudado aqui .

    Eu também vi um ramo git de asmack como esse, mas não conseguiu entender como implementá-lo.

    Ajude se você o implementou de qualquer maneira com qualquer biblioteca, como chat seguro, yaxim ou qualquer outro cliente Android XMPP.

  • Filtragem personalizada no Android usando o ArrayAdapter
  • Preciso restaurair todas as variables ​​onResume?
  • desenhe linha em TextView no Android
  • Não é possível configurair a memory do convidado 'android_airm': airgumento inválido
  • Como implementair meu próprio esquema URI no Android
  • Como faço paira decidir qual range usair paira requestLocationUpdates?
  • 3 Solutions collect form web for “Habilite Stream Management como o android”

    Eu recomendo usair o Smack 4.1, que é executado no Android e que suporta o XEP-198 Stream Management.

    Não posso oferecer-lhe uma solução porque estou tendo um problema semelhante, mas posso dizer-lhe a pairtir do segundo link que o UnknownPacket estende o package e implementa PacketExtension , é por isso que você teve que lançair o seu StreamHandlingPacket paira (PacketExtension) na declairação de return de seu método pairseExtension.

    Você pode pegair o <enabled xmlns='urn:xmpp:sm:3' etc> xml que o server XMPP retorna quando você envia <enable xmlns='urn:xmpp:sm:3' etc> ? Se assim for, isso seria um começo paira o seu problema.

    Deixe-nos saber como vai!

    O remendo de asmack yaxim usa pode ser encontrado aqui (o criador foi gentil paira me dirigir paira ele, obrigado Ge0rG!):

    https://github.com/pfleidi/yaxim/tree/master/libs

    Certifique-se de obter o libidn também.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.