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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:41:07+00:00 2026-06-05T09:41:07+00:00

I’ve been working on a simple app for android – and i’m trying to

  • 0

I’ve been working on a simple app for android – and i’m trying to login using Single Sign-On using the Facebook Android SDK.

I’m trying to save the profile picture and username. I’m not quite sure what’s wrong – but nothing seems to happen after I Sign In on Facebook.

Here’s my code:

public class fbLogin extends Activity {
 Facebook facebook = new Facebook("MY-APP-ID");
 private SharedPreferences mPrefs;
 public boolean flag=false;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.fblogin_screen);
        mPrefs=getPreferences(MODE_PRIVATE);
        String acces_token=mPrefs.getString("acces_token",null);
        long expires=mPrefs.getLong("acces_expires", 0);

        if(acces_token!=null)
        {
            facebook.setAccessToken(acces_token);
        }
        if(expires!=0)
        {
            facebook.setAccessExpires(expires);
        }

        if(!facebook.isSessionValid())
        {
        facebook.authorize(this, new DialogListener() {

            public void onComplete(Bundle values) {
                flag=true;
                 SharedPreferences.Editor editor = mPrefs.edit();
                 editor.putString("access_token", facebook.getAccessToken());
                 editor.putLong("access_expires", facebook.getAccessExpires());
                 editor.commit();

            }

            public void onFacebookError(FacebookError error) {}

            public void onError(DialogError e) {}

            public void onCancel() {}
        });
    } else{
        flag=true;
        }

        if(flag==true)
        {
            try {
                JSONObject me = new JSONObject(facebook.request("me"));
                String id=me.getString("id");
                String userName=me.getString("username");
                ImageView picture;
                TextView usr = (TextView)findViewById(R.id.userName);
                picture = (ImageView) findViewById(R.id.profilePicture);
                URL image_value= new URL("http://graph.facebook.com/" + userName + "/pictures" );
                Bitmap profPict=BitmapFactory.decodeStream(image_value.openConnection().getInputStream());
                picture.setImageBitmap(profPict);
                usr.setText(userName);
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

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

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

What am I doing wrong?

  • 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-05T09:41:08+00:00Added an answer on June 5, 2026 at 9:41 am

    Change this
    URL image_value= new URL(“http://graph.facebook.com/” + userName + “/pictures” );
    to this
    URL image_value= new URL(“http://graph.facebook.com/” + userName + “/picture” );

    • 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
We're building an app, our first using Rails 3, and we're having to build
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is

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.