Quantcast
Channel: Ignite Realtime : Unanswered Discussions - Support
Viewing all articles
Browse latest Browse all 4979

how to get openfire registered users from android client using aSmack

$
0
0

Hi All,

i am trying to create chat app.

- I installed openfire server in my local machine

- And added some users through openfire server admin panel

- Now i am trying to display all available users in android Emulator. iam using android 4 and asmack-android-19-0.8.10.jar

- I am able to connected to openfire server usign aSmack lib. But not possible to fetch all avaialble users using Roster.

My code sample using in AsyncTask doInBackground method :

 

           ConnectionConfiguration config = new ConnectionConfiguration("10.42.0.3", 5222, "localhost");

            connection = new XMPPConnection(config);

 

            try {

                connection.connect();

                Log.d("SMACK ", " CONNECTED");

                

               

             // list online contacts

                Roster roster = connection.getRoster();

                Collection<RosterEntry> entries = roster.getEntries();

                Log.d("TRACE", "entries.size()=" + entries.size());

                for (RosterEntry e : entries) {

                   Log.d("PRESENCE", e.getUser() + "=" + roster.getPresence(e.getUser()).isAvailable());

                   if (roster.getPresence(e.getUser()).isAvailable()) {

                      Log.d("ADD", "NAME_KEY=" + e.getName() + " USERJID_KEY=" + e.getUser());

                      //contacts.add(contact);

                   }

                }

           }

            catch (XMPPException e){

                Log.e("XMPPChatDemoActivity", "Failed to connect to "+ connection.getHost());

                Log.e("XMPPChatDemoActivity", e.toString());

            }

 

 

This code always gives "entries.size()" is ZERO.

 

Please suggest me how can i get registered users?

And how to registered users to openserver through Android client?

 

I explored internet from few days. But i did not get LUCK.

 

Please help me...

Thanks in advance...


Viewing all articles
Browse latest Browse all 4979

Trending Articles