Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9057593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:29:48+00:00 2026-06-16T14:29:48+00:00

i am getting friends list from facebook and populating in list view it works

  • 0

i am getting friends list from facebook and populating in list view it works fine but now i am trying to add Progress bar till the list view populates but getting exception i have tried searching but not found solution for my issue, here is my code:

public class FriendsProgress extends AsyncTask<Object, Void, Boolean>
    {
        @Override
        protected Boolean doInBackground(Object... Params)
        {
            try
            {
                getFriendList();                                                                    
                friendAdapter = new FriendAdapter(Friends.this, R.layout.activity_friends, friendsList);

                Friends.this.runOnUiThread(new Runnable()
                {
                @Override
                public void run()
                {

                    list.setAdapter(friendAdapter);
                    //list.setOnItemClickListener(EditStaff.this);

                }
                });


            }
            catch (Exception e)
            {
                System.out.println("StaffProgess Exception Caught:"+e.getMessage());
            }
            return Boolean.TRUE;
        }

        @Override
        protected void onPreExecute()
        {

            friendsProgress=new ProgressDialog(Friends.this);
            friendsProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
            friendsProgress.setIndeterminate(true);
            friendsProgress.setMessage("Loading...");       
            friendsProgress.setOwnerActivity(Friends.this);
            friendsProgress.show();

        }

        @Override
        protected void onPostExecute(Boolean Result) 
        {
            friendsProgress.dismiss();
            friendAdapter.notifyDataSetChanged();

        }
    }

here is getFriendsList function implementation:

public void getFriendList(){

        Request request = Request.newMyFriendsRequest(Session.getActiveSession(), new Request.GraphUserListCallback() {

            @Override
            public void onCompleted(List<GraphUser> users, Response response) {
                // TODO Auto-generated method stub

                for(int i=0; i<users.size();i++)
                {
                GraphUser user =    users.get(i);
                Friend objFriend = new Friend();
                objFriend.setFriendID(user.getId());
                objFriend.setFriendName(user.getName());
                Drawable dd =Friends.LoadImageFromWebOperations("http://graph.facebook.com/" + objFriend.getFriendID() + "/picture");
                objFriend.setFriendPic(dd);
                //objFriend.setFriendPic("http://graph.facebook.com/" + objFriend.getFriendID() + "/picture");
                friendsList.add(objFriend);
                //friendAdapter.notifyDataSetChanged();
                Log.d("Friend's Id", objFriend.getFriendID());
                Log.d("Friend's Name", objFriend.getFriendName());
                //Log.d("Friend's Pic", objFriend.getFriendPic());
                Log.d("Friend's List Count", Integer.toString(friendsList.size()));
                }


        }
    });
    Request.executeBatchAsync(request);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:29:50+00:00Added an answer on June 16, 2026 at 2:29 pm

    You shouldn’t instantiate an Adapter and link it to a ListView inside the doInBackground() method, because it’s running on a worker thread, and no operations connected to Android Views are permitted to be executed on a worker thread. Instead you might want to move this code

    friendAdapter = new FriendAdapter(Friends.this, R.layout.activity_friends, friendsList);
    
                Friends.this.runOnUiThread(new Runnable()
                {
                @Override
                public void run()
                {
    
                    list.setAdapter(friendAdapter);
                    //list.setOnItemClickListener(EditStaff.this);
    
                }
                });
    

    to the onPostExecute() method. This is surely a better designed solution. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What i am doing is getting friends list from facebook and trying to populate
i'm getting json data from the facebook-graph-api about: my relationship with my friends my
I am trying to get the list of specific user`s friends from twitter. This
I am using jQuery.getJSON to fetch the Facebook friends list, but I am not
Im getting my data from a web service and loads to a list view.
Hi I am using following FQL to fetch friends list from facebook and their
I'm trying to request some information from facebook's FQL, but the request is a
Hi friends i'm getting json from server (using kohana framework 3.0) like this.... {
I'm having some problems getting the Friend List of a twitter user from R,
i'm trying to make an application, getting all the birthdays and other information from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.