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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:45:24+00:00 2026-06-11T07:45:24+00:00

I am trying to upload an image on facebook. Using this code private void

  • 0

I am trying to upload an image on facebook. Using this code

      private void getFb()
    {

        final SharedPreferences mPrefs = getSharedPreferences(
                "fbPref", Activity.MODE_PRIVATE);

        String access_token = mPrefs.getString("access_token", null);
        long expires = mPrefs.getLong("access_expires", 0);
        if(access_token != null) {
            fb.setAccessToken(access_token);
        }
        if(expires != 0) {
            fb.setAccessExpires(expires);
        }

        if(!fb.isSessionValid()) 
        {
            fb.authorize(this, new String[] {"publish_stream"}, new DialogListener() {
                public void onComplete(Bundle values) {
                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putString("access_token", fb.getAccessToken());
                    editor.putLong("access_expires", fb.getAccessExpires());
                    editor.commit();
                }

                public void onFacebookError(FacebookError error) {}

                public void onError(DialogError e) {}

                public void onCancel() {}
            });
        }

    }



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

        Bundle parameters = new Bundle();
  //      parameters.putString(Facebook.TOKEN, fb.getAccessToken());
        // The byte array is the data of a picture.
        parameters.putString("message", "LolCats Test");
parameters.putString("picture", "http://cdn3.f-cdn.com/ppic/514992/logo/597178/profile_logo_597178.jpg");
parameters.putString("caption", "LLoll casts");

        try {
            fb.request("me/photos", parameters, "POST");

        } catch (FileNotFoundException fileNotFoundException) {
           // makeToast(fileNotFoundException.getMessage());
        } catch (MalformedURLException malformedURLException) {
          //  makeToast(malformedURLException.getMessage());
        } catch (IOException ioException) {
         //   makeToast(ioException.getMessage());
        }

    }

The only thing that happens is a page with FB app opens , do some progress bar and then back to the application, no error etc. What is wrong with image not getting shared on facebook?

  • 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-11T07:45:25+00:00Added an answer on June 11, 2026 at 7:45 am

    Made it to work with this code….

    private void getFb()
            {
                fb = new Facebook(Constants.facebookKey);
                String[] arrayOfString = new String[1];
                arrayOfString[0] = "publish_stream";
                fb.authorize(this, arrayOfString, new FBDialogListener());
            }
    
            @Override
            public void onActivityResult(int requestCode, int resultCode, Intent data) 
            {
                super.onActivityResult(requestCode, resultCode, data);
                fb.authorizeCallback(requestCode, resultCode, data);
            }
    
    
            private class FBDialogListener implements Facebook.DialogListener
            {
    
                public void onComplete(Bundle values)
                {
                    Bundle localBundle = new Bundle();
                    String str1 = "Myapp";
                    String str2 = "This image is by Myapp, app for Android.";
                    String str3 = "Download It";
                    Object[] arrayOfObject = new Object[6];
                      arrayOfObject[0] = str1;
                      arrayOfObject[1] = str2;
                      arrayOfObject[2] = bitmapUrls.get(currentPosition);
                      arrayOfObject[3] = bitmapUrls.get(currentPosition);
                      arrayOfObject[4] = str3;
                      arrayOfObject[5] = "http://play.google.com/store/apps/details?id=myapp";
                      localBundle.putString("attachment", String.format("{\"name\":\"%s:\",\"href\":\"\",\"caption\":\"\",\"description\":\"%s\",\"media\":[{\"type\":\"image\",\"src\":\"%s\",\"href\":\"%s\"}],\"properties\":{\"%s\":{\"text\":\"Android market\",\"href\":\"%s\"}}}", arrayOfObject));
                      fb.dialog(ImageActivity.this, "stream.publish", localBundle, new PublishDialogListener());
    
                }
    
                public void onFacebookError(FacebookError e) {
                }
    
                public void onError(DialogError e) {                
                }
    
                public void onCancel() {
    
                }
            }
    
            private class PublishDialogListener implements Facebook.DialogListener
            {
    
                public void onComplete(Bundle values) {
                    Toast.makeText(ImageActivity.this,  "Image has been shared"  , Toast.LENGTH_LONG).show();
                }
    
                public void onFacebookError(FacebookError e) {
                }
    
                public void onError(DialogError e) {
                }
    
                public void onCancel() {
                }
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload image to Amazon S3 with this Ruby code: require 'net/http/post/multipart'
I'm trying to upload an image to facebook using the iOS SDK from Facebook.
i am trying to upload an image from a jsp page using servlet. but
I have this Form I am trying to upload my image but every time
I am trying to upload a image to a gallery on a facebook fan
I am trying to upload an image to server using iphone . I haven't
I was trying to upload a photo on facebook using a browser with no
i am trying to upload photo to facebook using fiddler In the request builder
I'm currently trying to upload an image from my Mac application to Facebook. To
I am trying to let the user upload an image from my facebook app

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.