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 7081315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:54:19+00:00 2026-05-28T06:54:19+00:00

I’ve been trying to implement the Facebook SDK into my application in order to

  • 0

I’ve been trying to implement the Facebook SDK into my application in order to let users post messages on our fanwall through the app. However, I’ve been unsuccessful at even logging the user in through the SDK.

In the SDK examples, a simple sample has been given which uses an Activity to try and authorize the user using Single Sign-On. I’ve tried this example myself, and it works. I’m able to log in, I had to authorize the app to use my Facebook data and I could see the requests being made and received in LogCat.

Now, I’ve tried adding the same code to my own app. This app is Fragment based using the Compatibility package. There is one central FragmentActivity and the rest of my classes are simple Fragments. When adding the sample code to one of these Fragments, the Facebook app starts up for half a second when trying to authorize, but afterwards closes and nothing has happened. I’m back in my regular Fragment again.

When checking the LogCat after this, nothing suggests that the Facebook app even opened or made any requests other than the fact it shows some printing checks I added and the fact it says it’s starting the Facebook intent :

01-12 13:19:40.874: I/System.out(6087): Calling authorize
01-12 13:19:40.874: I/ActivityManager(1380): Starting activity: Intent { cmp=com.facebook.katana/.ProxyAuth (has extras) } from pid 6087
01-12 13:19:40.874: I/System.out(6087): Called authorize

Other than that, nothing gets returned. No Facebook-checks, no statements saying my keys are wrong or anything, just nothing. The Facebook intent was called, but closed almost immediately and nothing else shows that it was even open.

This has been boggling my mind for a few hours now, and I’m starting to think the regular , sample-provided approach just doesn’t work in Fragments due to the way Fragments work.

The code I’ve been using is posted below. The Fragment gets fired by a button which calls a FragmentTransaction. Am I doing something fundamentally wrong here, or does the Facebook SDK really just not work with Fragments? I’ve tried searching for this problem but I haven’t been able to find anyone else with the same sort of situation.


public class FanWallFacebook extends Fragment {

    Facebook facebook = new Facebook("294678133912628");

    public FanWallFacebook() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.filler, container, false);
    }

    @Override
    public void onStart() {
        super.onStart();

        System.out.println("Calling authorize");
        facebook.authorize(getActivity(), new DialogListener() {
            @Override
            public void onComplete(Bundle values) {
                System.out.println("Completed");
            }

            @Override
            public void onFacebookError(FacebookError error) {
                System.out.println("Facebook error: "+error.getMessage());
            }


            @Override
            public void onError(DialogError e) {
                System.out.println("General error: "+e.getMessage());
            }

            @Override
            public void onCancel() {
                System.out.println("Cancelled");
            }
        });

        System.out.println("Called authorize");

    }

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

        facebook.authorizeCallback(requestCode, resultCode, data);
        System.out.println("Authorize callback'd");
    }

}

Edit

Just tried using a FragmentActivity, and lo and behold, that does work. It successfully logs in. Seems like the SDK really only works with classes that explicitly extend ...Activity. Could anyone give me an idea why that might be the case? I always thought Fragments somewhere down the line extended Activity as well.

  • 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-28T06:54:20+00:00Added an answer on May 28, 2026 at 6:54 am

    I ended up using a FragmentActivity for my Facebook interaction. Not the ideal solution, but it works.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to create an if statement in PHP that prevents a single post
I have a jquery bug and I've been looking for hours now, I can't
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.