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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:57:43+00:00 2026-06-17T15:57:43+00:00

The first time I login with facebook SDK, it works without any error. But

  • 0

The first time I login with facebook SDK, it works without any error. But when I tried log out and login again, facebook error appears. The error is "Facebook error: an active access token must be used to query information about the current user" and the getAccessToken() returns as null. Any answer and comment will be appreciated.

Login Activity.java

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        if (APP_ID == null) {
        Util.showAlert(this, "Warning", "Facebook Application ID must be specified before running");
    }
    try {
       PackageInfo info = getPackageManager().getPackageInfo("com.ff.fbin", PackageManager.GET_SIGNATURES);
       for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.e("TAG", "Reverse FB key: "+Base64Coder.encodeLines(md.digest()));
       }
    } catch (NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }



    mLoginButton = (LoginButton) findViewById(R.id.login);
    mFacebook = new Facebook(APP_ID);
    mAsyncRunner = new AsyncFacebookRunner(mFacebook);
    SessionStore.restore(mFacebook, this);
    SessionEvents.addAuthListener(new SampleAuthListener());
    SessionEvents.addLogoutListener(new SampleLogoutListener());
    mLoginButton.init(this, mFacebook, mPermissions);
 }


@Override
protected void onActivityResult(int requestCode, int resultCode,
                                Intent data) {
    mFacebook.authorizeCallback(requestCode, resultCode, data);

    boolean isLogined = mFacebook.isSessionValid();
    Log.i(TAG, "getAccessToken, onActivity:" +mFacebook.getAccessToken());

    if (isLogined){
        mAsyncRunner.request("me", new SampleRequestListener());
    }
}

public class SampleRequestListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        try {
            Log.d(TAG, "Response2: " + response.toString());
            JSONObject json = Util.parseJson(response);

            //Retrieve user information from facebook

final Runnable mUpdateResultsSuccess = new Runnable() {
    @Override
    public void run() {
        updateResultsInUiSuccess();
    }
};

private void updateResultsInUiSuccess() {
        if (loginSuccess){
            Log.i(TAG, "Login FB done");
            finish();
            Intent intent2 = new Intent(LoginScreen.this, MainMenu.class);
            helper.insert_user(mFacebook.getAccessToken());
            intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent2);

        } else {
            loading_text.setText("Error Processing");
            Log.i(TAG, "Login FB failed");
            try {
                mFacebook.logout(this);
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Log.e(TAG, "MalformedURLException: "+e.getMessage());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Log.e(TAG, "IOException: "+e.getMessage());
            }
            SessionStore.clear(this);
            pDialog.dismiss();
            Toast.makeText(LoginScreen.this, "Login Failed. Please try again", Toast.LENGTH_LONG).show();
        }
}


public class SampleAuthListener implements com.ff.fbin.SessionEvents.AuthListener {

    @Override
    public void onAuthSucceed() {
        Log.i(TAG, "You have logged in! ");

        boolean isLogined = mFacebook.isSessionValid();
        Log.i(TAG, "isLogined: "+isLogined);

        if(!isFinishing()){

        };

        if (isLogined){
            mAsyncRunner.request("me", new SampleRequestListener());
            pDialog.setMessage("Login in process......");
            pDialog.show();
        }

    }

    @Override
    public void onAuthFail(String error) {
        Log.i(TAG, "Login Failed: " + error);
        Toast.makeText(getApplicationContext(), "Login Failed: " + error, Toast.LENGTH_LONG).show();
        pDialog.dismiss();
    }
}

public class SampleLogoutListener implements com.ff.fbin.SessionEvents.LogoutListener {
    @Override
    public void onLogoutBegin() {
        Log.i(TAG, "Logging out...");
    }

    @Override
    public void onLogoutFinish() {
        Log.i(TAG, "You have logged out! ");
    }
}
  • 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-17T15:57:44+00:00Added an answer on June 17, 2026 at 3:57 pm

    Question solved, apparently the issue came from these sessionEvents. SessionEvents.addAuthListener(new SampleAuthListener());
    SessionEvents.addLogoutListener(new SampleLogoutListener());

    I removed the above code and move SessionStore.restore into onResume and it worked without error. The above code keep on create new SampleAuthListener() and causing it to stack together and do the same thing multiple times. That’s the reason cause facebook error for my project.

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

Sidebar

Related Questions

I installed an facebook login extension named inchoo.First time it runs perfect in localhost,ie.
I am currently implementing Facebook Login on my website for the first time and
First time working with JSON in Rails and trying to figure out something which
first time posting here. I'm using a loop to create 3 buttons, but my
Users have been able to log into my website using their Facebook account, but
This is the first time I have integrated facebook into an app so I
After I integrate the Facebook Invite Friends plug-in, the first time it’s loaded in
I notice that some games use Facebook SDK to login to their game. The
I am trying to use the FBConnect SDK to connect to Facebook. Everything works
I'm using the facebook ios Sdk to connect my application with facebook. The login

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.