Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

Not able to connect using aSmack android asmack-android-8-4.0.0-rc2.jar

$
0
0

Hello ,

 

 

I just create app for Connect with Openfire server host at our network and i am try to connect it by andorid app .

 

 

Below is my code ,But it is not working. and i am also not able to find RosterExchangeProvider class in jar .

 

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_xmpp);

 

        if (savedInstanceState == null) {

            getSupportFragmentManager().beginTransaction()

                    .add(R.id.container, new PlaceholderFragment()).commit();

        }

               

        SmackAndroid.init(this);

                       

        new XmppClientTask().execute();

       

    }

 

 

public class XmppClientTask extends AsyncTask<Void, Void, Void>{

 

        @Override

        protected Void doInBackground(Void... params) {

           

            System.setProperty("java.net.preferIPv6Addresses", "false");

           

            //mConnectionConfiguration=new ConnectionConfiguration(mServerAddress, mPort, mServiceName);

           

            configure();

           

            mConnectionConfiguration=new ConnectionConfiguration(mServerAddress);

           

           

            mXmppConnection=new XmppChat(mConnectionConfiguration);

           

            try{

               

                mXmppConnection.connect();

               

                mXmppConnection.login(mUserName, mPass);

       

                presence=new Presence(Presence.Type.available);

               

                mXmppConnection.sendPacket(presence);

               

                Roster mRoster=mXmppConnection.getRoster();

               

                Collection<RosterEntry> mUserList=mRoster.getEntries();

               

                Log.i("LOG_TAG", "Total User Found in Chat "+ mUserList.size());

                               

               

            }catch(XMPPException Exc){

               

                Exc.printStackTrace();

               

            }catch (SaslException e) {

                // TODO Auto-generated catch block

                e.printStackTrace();

            } catch (SmackException e) {

                // TODO Auto-generated catch block

                e.printStackTrace();

            } catch (IOException e) {

                // TODO Auto-generated catch block

                e.printStackTrace();

            }

           

            return null;

        }

       

    }

 

 

public void configure() {

 

       // Private Data Storage

 

       ProviderManager.addIQProvider("query", "jabber:iq:private",

 

               new PrivateDataManager.PrivateDataIQProvider());

 

       // Time

 

       try {

 

           ProviderManager.addIQProvider("query", "jabber:iq:time",

                       Class.forName("org.jivesoftware.smackx.packet.Time"));

 

       } catch (ClassNotFoundException e) {

 

           Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Time");

 

       }

 

       // Roster Exchange

 

       /*ProviderManager.addExtensionProvider("x", "jabber:x:roster",

               new RosterExchangeProvider());*/

 

      

       // Message Events

 

       ProviderManager.addExtensionProvider("x", "jabber:x:event",

               new MessageEventProvider());

 

 

 

       // Chat State

 

       ProviderManager.addExtensionProvider("active",

 

               "http://jabber.org/protocol/chatstates",

 

               new ChatStateExtension.Provider());

 

       ProviderManager.addExtensionProvider("composing",

 

               "http://jabber.org/protocol/chatstates",

 

               new ChatStateExtension.Provider());

 

       ProviderManager.addExtensionProvider("paused",

 

               "http://jabber.org/protocol/chatstates",

 

               new ChatStateExtension.Provider());

 

       ProviderManager.addExtensionProvider("inactive",

 

               "http://jabber.org/protocol/chatstates",

 

               new ChatStateExtension.Provider());

 

       ProviderManager.addExtensionProvider("gone",

 

               "http://jabber.org/protocol/chatstates",

 

               new ChatStateExtension.Provider());

 

 

 

       // XHTML

 

       ProviderManager.addExtensionProvider("html", "http://jabber.org/protocol/xhtml-im",

 

               new XHTMLExtensionProvider());

 

 

 

       // Group Chat Invitations

 

       ProviderManager.addExtensionProvider("x", "jabber:x:conference",

 

               new GroupChatInvitation.Provider());

 

 

 

       // Service Discovery # Items

 

       ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#items",

 

               new DiscoverItemsProvider());

 

 

 

       // Service Discovery # Info

 

       ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#info",

 

               new DiscoverInfoProvider());

 

 

 

       // Data Forms

 

       ProviderManager.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());

 

 

 

       // MUC User

 

       ProviderManager.addExtensionProvider("x", "http://jabber.org/protocol/muc#user",

 

               new MUCUserProvider());

 

 

 

       // MUC Admin

 

       ProviderManager.addIQProvider("query", "http://jabber.org/protocol/muc#admin",

 

               new MUCAdminProvider());

 

 

 

       // MUC Owner

 

       ProviderManager.addIQProvider("query", "http://jabber.org/protocol/muc#owner",

 

               new MUCOwnerProvider());

 

 

 

       // Delayed Delivery

 

       ProviderManager.addExtensionProvider("x", "jabber:x:delay",

 

               new DelayInformationProvider());

 

 

 

       // Version

 

       try {

 

           ProviderManager.addIQProvider("query", "jabber:iq:version",

 

                   Class.forName("org.jivesoftware.smackx.packet.Version"));

 

       } catch (ClassNotFoundException e) {

 

           // Not sure what's happening here.

 

       }

 

 

 

       // VCard

 

       ProviderManager.addIQProvider("vCard", "vcard-temp", new VCardProvider());

 

 

 

       // Offline Message Requests

 

       ProviderManager.addIQProvider("offline", "http://jabber.org/protocol/offline",

 

               new OfflineMessageRequest.Provider());

 

 

 

       // Offline Message Indicator

 

       ProviderManager.addExtensionProvider("offline",

 

               "http://jabber.org/protocol/offline",

 

               new OfflineMessageInfo.Provider());

 

 

 

       // Last Activity

 

       ProviderManager.addIQProvider("query", "jabber:iq:last", new LastActivity.Provider());

 

 

 

       // User Search

 

       ProviderManager.addIQProvider("query", "jabber:iq:search", new UserSearch.Provider());

 

 

 

       // SharedGroupsInfo

 

       ProviderManager.addIQProvider("sharedgroup",

 

               "http://www.jivesoftware.org/protocol/sharedgroup",

 

               new SharedGroupsInfo.Provider());

 

 

 

       // JEP-33: Extended Stanza Addressing

 

       ProviderManager.addExtensionProvider("addresses",

 

               "http://jabber.org/protocol/address",

 

               new MultipleAddressesProvider());

 

 

 

       // FileTransfer

 

       ProviderManager.addIQProvider("si", "http://jabber.org/protocol/si",

 

               new StreamInitiationProvider());

 

 

 

       ProviderManager.addIQProvider("query", "http://jabber.org/protocol/bytestreams",

 

               new BytestreamsProvider());

 

 

 

       // Privacy

 

       ProviderManager.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());

 

       ProviderManager.addIQProvider("command", "http://jabber.org/protocol/commands",

 

               new AdHocCommandDataProvider());

 

       ProviderManager.addExtensionProvider("malformed-action",

 

               "http://jabber.org/protocol/commands",

 

               new AdHocCommandDataProvider.MalformedActionError());

 

       ProviderManager.addExtensionProvider("bad-locale",

 

               "http://jabber.org/protocol/commands",

 

               new AdHocCommandDataProvider.BadLocaleError());

 

       ProviderManager.addExtensionProvider("bad-payload",

 

               "http://jabber.org/protocol/commands",

 

               new AdHocCommandDataProvider.BadPayloadError());

 

       ProviderManager.addExtensionProvider("bad-sessionid",

 

               "http://jabber.org/protocol/commands",

 

               new AdHocCommandDataProvider.BadSessionIDError());

 

       ProviderManager.addExtensionProvider("session-expired",

 

               "http://jabber.org/protocol/commands",

 

               new AdHocCommandDataProvider.SessionExpiredError());

 

   }

 

I am getting below Error  : 

 

06-20 08:48:38.262: D/gralloc_goldfish(7468): Emulator without GPU emulation detected.

06-20 08:48:38.412: W/TestClient(7468): Can't load class for org.jivesoftware.smackx.packet.Time

06-20 08:48:38.922: D/dalvikvm(7468): GC_FOR_ALLOC freed 218K, 10% free 2994K/3292K, paused 28ms, total 29ms

06-20 08:48:39.042: D/dalvikvm(7468): GC_FOR_ALLOC freed 249K, 12% free 3161K/3556K, paused 24ms, total 24ms

06-20 08:48:39.482: D/dalvikvm(7468): GC_FOR_ALLOC freed 309K, 11% free 3364K/3752K, paused 24ms, total 24ms

06-20 08:48:40.002: D/dalvikvm(7468): GC_FOR_ALLOC freed 365K, 12% free 3506K/3952K, paused 29ms, total 29ms

06-20 08:48:40.302: W/System.err(7468): org.jivesoftware.smack.SmackException$NotConnectedException

06-20 08:48:40.302: W/System.err(7468):     at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:579)

06-20 08:48:40.312: W/System.err(7468):     at com.brainvire.xmppdemo.XmppActivity$XmppClientTask.doInBackground(XmppActivity. java:154)

06-20 08:48:40.312: W/System.err(7468):     at com.brainvire.xmppdemo.XmppActivity$XmppClientTask.doInBackground(XmppActivity. java:1)

06-20 08:48:40.312: W/System.err(7468):     at android.os.AsyncTask$2.call(AsyncTask.java:288)

06-20 08:48:40.322: W/System.err(7468):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)

06-20 08:48:40.322: W/System.err(7468):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)

06-20 08:48:40.322: W/System.err(7468):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)

06-20 08:48:40.322: W/System.err(7468):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

06-20 08:48:40.332: W/System.err(7468):     at java.lang.Thread.run(Thread.java:841)


Viewing all articles
Browse latest Browse all 10742

Trending Articles