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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:55:31+00:00 2026-06-09T22:55:31+00:00

I’m trying to do a simple Facebook Login in my app, but I got

  • 0

I’m trying to do a simple Facebook Login in my app, but I got some questions about SharedPreferences.

The idea is the App starts and goes to Activity A, it sees if you’re logged in, if you aren’t then it sends you to Activity B, you login and go back to A.

What’s happening is that when I log in at B, it sends me back to A, but A doesn’t appear to load my SharedPreferences and send me back to B, and I got into a loop.

That’s my code in A.

public static String access_token = null;
long expires;

…

private void SharedP() {
    // TODO Auto-generated method stub
    prefs = getSharedPreferences(access_token, MODE_PRIVATE);
    access_token = prefs.getString("access_token", null);
    expires = prefs.getLong("access_expires", 0);
    if (access_token == null && expires == 0) { //If it's not logged...
        Intent login = new Intent("android.intent.action.FACEBOOKLOGIN");
        startActivity(login);
    }
}

What am I doing wrong? How should I do it?

My code in B:

public void onComplete(Bundle values) {
                // TODO Auto-generated method stub
                Editor edit = fbSP.edit();
                edit.putString("access_token", fb.getAccessToken());
                edit.putLong("access_expires", fb.getAccessExpires());
                edit.commit();
                UpdateLoginImage();
                BackToA();
            }
  • 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-09T22:55:32+00:00Added an answer on June 9, 2026 at 10:55 pm

    It seems to me that you are not reading the same shared preferences on A and B.

    getSharedPreferences(access_token, MODE_PRIVATE)opens an “access_token” shared preferences file, you should use a file name like getSharedPreferences("facebook_data", MODE_PRIVATE).

    Then in activity B, if you follow the Facebook guide on login for android, it uses the activity sharedPreferences getPreferences(MODE_PRIVATE). This second one returns a preferences file only accesible for the activity B. I’m just guessing this because i don’t have your code, maybe you got that ok.

    Check if you are opening the same sharedPreferences file on both activities.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
This could be a duplicate question, but I have no idea what search terms
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
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.