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

  • Home
  • SEARCH
  • 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 6086671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:46:56+00:00 2026-05-23T11:46:56+00:00

just trying to allow my app to access basic information from an authenticated Facebook

  • 0

just trying to allow my app to access basic information from an authenticated Facebook user, yet my logcat tells me

06-30 16:37:27.969: WARN/System.err(1559): com.facebook.android.FacebookError: An active access token must be used to query information about the current user.

right after authentification where the code is ran. Can someone point me in the right direction? I’ve seen a very similar post where someone used almost identical code and It worked.

Thanks

Facebook facebook = new Facebook("187212574660004");

TextView nText;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    nText = (TextView) this.findViewById(R.id.nameText);

    facebook.authorize(this, new String[] {"offline_access", "user_interests", "friends_interests"},

            new DialogListener() {
        public void onComplete(Bundle values) {
            setContentView(R.layout.homepage);
        }

        public void onFacebookError(FacebookError error) {}

        public void onError(DialogError e) {}

        public void onCancel() {}
    });

    JSONObject json_data = null;

    try
    {
        JSONObject response = Util.parseJson(facebook.request("me/friends")); // Get a friend information from facebook
        JSONArray jArray = response.getJSONArray("data");

        json_data = jArray.getJSONObject(0);
        String name = json_data.getString("name");
        Log.i("friend is", name);
        nText.setText(name);

    }
    catch (MalformedURLException e)
    {
        e.printStackTrace();
    }
    catch (JSONException e)
    {
        e.printStackTrace();
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    catch (FacebookError e)
    {
        e.printStackTrace();
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    facebook.authorizeCallback(requestCode, resultCode, data);
}

Tried the method as described before by Manno23 and got

06-30 19:27:04.338: ERROR/AndroidRuntime(349): Caused by: java.lang.NullPointerException
06-30 19:27:04.338: ERROR/AndroidRuntime(349): at com.staffit.FacebookPage.getFriends(FacebookPage.java:67)
06-30 19:27:04.338: ERROR/AndroidRuntime(349): at com.staffit.FacebookPage.access$0(FacebookPage.java:55)
06-30 19:27:04.338: ERROR/AndroidRuntime(349): at com.staffit.FacebookPage$1.onComplete(FacebookPage.java:41)
06-30 19:27:04.338: ERROR/AndroidRuntime(349): at com.facebook.android.Facebook.authorizeCallback(Facebook.java:383)
06-30 19:27:04.338: ERROR/AndroidRuntime(349): at com.staffit.FacebookPage.onActivityResult(FacebookPage.java:93)
06-30 19:27:04.338: ERROR/AndroidRuntime(349): at android.app.Activity.dispatchActivityResult(Activity.java:3907)
06-30 19:27:04.338: ERROR/AndroidRuntime(349): at android.app.ActivityThread.deliverResults(ActivityThread.java:2492)
06-30 19:27:04.338: ERROR/AndroidRuntime(349): ... 11 more

  • 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-05-23T11:46:56+00:00Added an answer on May 23, 2026 at 11:46 am

    Both of the above answers are correct. You can just put the chunk of code that does the request into a separate method and call that method in onComplete(), i.e.

    Facebook facebook = new Facebook("XXXXXasdasdajksdad");
    
    TextView nText;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        nText = (TextView) this.findViewById(R.id.nameText);
    
        facebook.authorize(this, new String[] {"offline_access", "user_interests", "friends_interests"},
    
                new DialogListener() {
            public void onComplete(Bundle values) {
                getFriends();
                setContentView(R.layout.homepage);
            }
    
            public void onFacebookError(FacebookError error) {}
    
            public void onError(DialogError e) {}
    
            public void onCancel() {}
        });
    
    
    }
    
    private void getFriends(){
    
        JSONObject json_data = null;
    
        try
        {
            JSONObject response = Util.parseJson(facebook.request("me/friends")); // Get a friend information from facebook
            JSONArray jArray = response.getJSONArray("data");
    
            json_data = jArray.getJSONObject(0);
            String name = json_data.getString("name");
            Log.i("friend is", name);
            nText.setText(name);
    
        }
        catch (MalformedURLException e)
        {
            e.printStackTrace();
        }
        catch (JSONException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        catch (FacebookError e)
        {
            e.printStackTrace();
        }
    
    }
    
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    
        facebook.authorizeCallback(requestCode, resultCode, data);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get just a piece of information from Facebook, but I don't
I'm trying to write an app to allow the user to step through a
I am simply trying to setup Facebook Connect to allow the choice on my
Im trying to build a facebook app using the c# sdk Part of the
Just trying to get my head around Generics by reading this enlightening article by
Just trying to get my irb sessions to actually list the current line of
Just trying to get up to speed with the SDK... So, I've created my
Just trying to get my head round Spring and figuring out how I wire
Just trying to get diff to work better for certain kinds of documents. With
just trying to test for equality in this piece of code, but getting a

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.