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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:32:23+00:00 2026-06-06T10:32:23+00:00

I have created my android code wherein I fetch all the data from facebook

  • 0

I have created my android code wherein I fetch all the data from facebook and then displays it in a textView and it works just fine on my account. But after I tried to connect with my dummy account, no details is fetched and I don’t know the cause of this problem. Well here’s my code to review:

private void getFbName() {
    mProgress.setMessage("Finalizing ...");
    mProgress.show();

    new Thread() {
        @Override
        public void run() {
            String name = "";
            int what = 1;

            try {
                String me = mFacebook.request("me");

                JSONObject jsonObj = (JSONObject) new JSONTokener(me).nextValue();
                name = jsonObj.getString("first_name") + "|" + jsonObj.getString("last_name") + "|" + jsonObj.getString("email") + "|" + jsonObj.getString("id");
                what = 0;
            }
            catch (Exception ex) {
                ex.printStackTrace();
            }

            mFbHandler.sendMessage(mFbHandler.obtainMessage(what, name));
        }
    }.start();
}

private Handler mFbHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        mProgress.dismiss();

        if (msg.what == 0) {
            String username = (String) msg.obj;
            username = (username.equals("")) ? "No Name" : username;

            //SPLITTER
            String tokens[] = username.split("\\|");
            TextView fname = (TextView) findViewById(R.id.textView1);
            fname.setText(tokens[0]);

            TextView lname = (TextView) findViewById(R.id.textView2);
            lname.setText(tokens[1]);

            TextView eadd = (TextView) findViewById(R.id.textView3);
            eadd.setText(tokens[2]);

            TextView fbid = (TextView) findViewById(R.id.textView4);
            fbid.setText(tokens[3]);

            SessionStore.saveName(username, Main.this);
            //mFacebookBtn.setText("       Facebook (" + username + ")");

            Toast.makeText(Main.this, "Connected to Facebook as " + username, Toast.LENGTH_SHORT).show();
        }
        else {
            Toast.makeText(Main.this, "Connected to Facebook", Toast.LENGTH_SHORT).show();
        }
    }
};

Well I only followed this tutorial for my code with some modification in the design wherein I use 1 button for login and another for logout and then displays the result in 4 textViews.


Edit
Here’s my logout code:

private void fbLogout() {
    mProgress.setMessage("Disconnecting from Facebook");
    mProgress.show();

    new Thread() {
        @Override public void run() {
            SessionStore.clear(Main.this);
            int what = 1;
            try {
                mFacebook.logout(Main.this);
                what = 0;
            }
            catch (Exception ex) {
                ex.printStackTrace();
            }

            mHandler.sendMessage(mHandler.obtainMessage(what));
        }
    }.start(); 
}
  • 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-06T10:32:26+00:00Added an answer on June 6, 2026 at 10:32 am

    When using the facebook android SDK, you two have two types of authentication:

    1. Using the SDK auth dialog which will ask the user for his email/password.
    2. Using Single Sign-On (SSO) which will only work if the device has the facebook application (katana) installed. If that’s the case, that app will be responsible for the authentication which creates a better user experience since the user is already signed in and does not need to reenter his credentials.

    If you are following the tutorial then you are using SSO (if the app is installed of course), and because of that when ever you are using the facebook.authorize method you are asking the fb app to authorize your app for the current logged in user.
    If you want another user to use your app you’ll need the user to log out of the main facebook app.

    You can use the sdk authentication and bypass the SSO as suggested here: How to disable Facebook single sign on for android – Facebook-android-sdk, but as I said before, I think it results in a bad user experience.

    Another thing is that you keep implementing things using threads, but the facebook android SDK already gives you a helper class for that, it’s the AsyncFacebookRunner which makes api requests asynchronously, read Async API Requests.

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

Sidebar

Related Questions

Hi all I have created layout using following code <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have created an Android Library. That has all the main code. Also I
i have created a textview with the below code: <TextView android:id=@+id/txtDescription android:layout_width=fill_parent android:layout_height=wrap_content android:textSize=16dip
I have created an ExpandableListView with the following code: <ExpandableListView android:id=@+id/android:list android:layout_width=wrap_content android:layout_height=0dp android:layout_marginTop=5dp
I have created an App Widget for Android 1.5. It uses a TextView to
I have created a Java code for my Android App. String[] MovieName=new String[]{}; for
i have created a coverflow using the code given by http://android.jmsliu.com/138/android-infinite-loop-gallery.html . And it
I am new to Android.I have created a dynamic textview which is displayed on
I have successfully created an Android app that calculates prices and then is able
Hello i have created a sample application in android using eclipse IDE my code

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.