private static void addSimplePacketExtension(final String name, final String namespace) { ProviderManager.addExtensionProvider(name, namespace, new DataPacketProvider.PacketExtensionProvider() { public Stanza parseExtension(XmlPullParser parser) throws Exception { StreamHandlingPacket packet = new StreamHandlingPacket(name, namespace); int attributeCount = parser.getAttributeCount(); for (int i = 0; i < attributeCount; i++) { packet.addAttribute(parser.getAttributeName(i), parser.getAttributeValue(i)); } return packet; } }); }