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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:09:31+00:00 2026-06-05T14:09:31+00:00

I look all the internet and couldn’t find how do I post link with

  • 0

I look all the internet and couldn’t find how do I post link with a specific picture on facebook wall using fb sdk\api.

I know that this is part of the code that I need to use:

Facebook facebookClient = new Facebook("fb_App_id");

Bundle parameters = new Bundle();
parameters.putString("message", "Test Photo");
parameters.putString("link", "https://www.google.com");
parameters.putString("picture", "link to some pictrue");
facebookClient.dialog(MainActivity.this, "stream.publish", parameters, new DialogListener() {

@Override
public void onFacebookError(FacebookError e) {
    // TODO Auto-generated method stub

}

@Override
public void onError(DialogError e) {
    // TODO Auto-generated method stub

}

@Override
public void onComplete(Bundle values) {
    // TODO Auto-generated method stub

}

@Override
public void onCancel() {
    // TODO Auto-generated method stub

}
});

When I try to use this code I get “Source not found” error.
I think that I’m missing the connect\verification step…

How can I make it work?

Another thing: In case I use FB SDK in my personal app that I share on Google Play and this app is FREE but has Ads on it, Is it legal to use FB SDK in my app?

  • 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-05T14:09:32+00:00Added an answer on June 5, 2026 at 2:09 pm

    Finally I found how to do it.

    You need to declare this two:

    Facebook facebookClient;    
    SharedPreferences mPrefs;
    

    In the onCreate function I initialize facebookClient with the facebook AppID.

    The class that lunches the facebook share must be Activity

    There are three functions that I added to the activity:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        facebookClient.authorizeCallback(requestCode, resultCode, data);
    }
    
    public void loginToFacebook() {
        mPrefs = getPreferences(MODE_PRIVATE);
        String access_token = mPrefs.getString("access_token", null);
        long expires = mPrefs.getLong("access_expires", 0);
    
        if (access_token != null) {
            facebookClient.setAccessToken(access_token);
        }
    
        if (expires != 0) {
            facebookClient.setAccessExpires(expires);
        }
    
        if (!facebookClient.isSessionValid()) {
            facebookClient.authorize(this, new String[] { "publish_stream" }, new DialogListener() {
    
                @Override
                public void onCancel() {
                    // Function to handle cancel event
                }
    
                @Override
                public void onComplete(Bundle values) {
                    // Function to handle complete event
                    // Edit Preferences and update facebook acess_token
                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putString("access_token", facebookClient.getAccessToken());
                    editor.putLong("access_expires", facebookClient.getAccessExpires());
                    editor.commit();
    
                    postToWall();
                }
    
                @Override
                public void onError(DialogError error) {
                    // Function to handle error
    
                }
    
                @Override
                public void onFacebookError(FacebookError fberror) {
                    // Function to handle Facebook errors
    
                }
    
            });
        }
    }
    
    private void postToWall() {
        Bundle parameters = new Bundle();
        parameters.putString("name", "Battery Monitor");
        parameters.putString("link", "https://play.google.com/store/apps/details?id=com.ck.batterymonitor");
        parameters.putString("picture", "link to the picture");
        parameters.putString("display", "page");
        // parameters.putString("app_id", "228476323938322");
    
        facebookClient.dialog(MainActivity.this, "feed", parameters, new DialogListener() {
    
            @Override
            public void onFacebookError(FacebookError e) {
                // TODO Auto-generated method stub
    
            }
    
            @Override
            public void onError(DialogError e) {
                // TODO Auto-generated method stub
    
            }
    
            @Override
            public void onComplete(Bundle values) {
                // TODO Auto-generated method stub
            }
    
            @Override
            public void onCancel() {
                // TODO Auto-generated method stub
            }
        });
    }
    

    and at last:

            ImageButton facebookButton = (ImageButton) findViewById(R.id.button_FacebookShare);
            facebookButton.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
    
                    loginToFacebook();
    
                    if (facebookClient.isSessionValid()) {
                        postToWall();
                    }
                }
            });
    

    It does an auto login to facebook and then displaies facebook share\post dialog.
    The code was taken from this tutorial

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

Sidebar

Related Questions

Commonly when I look around the Internet, I find that people are generally using
As we all know most apps have a data access layer, often using repository
all. I've been scouring the internet, and I haven't found a conclusive answer to
I have searched the internet for drivers to connect to either database and all
First of all, the question is very simple, but I have tried to look
I'm making a game in OpenGL on Windows using Code::Blocks (C++) and MinGW. All
I search all through the internet and all topics about taking control of the
I've googled about this all over the Internet and still haven't found a solution.
I have been having a look to some post here related to the post
I'm having a problem with my HTML. I've searched all over the internet, but

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.