How do I share a page or link using the latest Fac

2019-06-14 11:28发布

问题:

I am trying to make an application which integrates facebook and twitter. I have started to implement Facebook for my application. And I have managed to do that using recently released Facebook SDK for android example

but now I am looking to share a page or a link to facebook using the same SDK but have no clue how to do it.

Can anyone please let me know how to do it. I am really stuck on this from long time.

回答1:

@Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.photo);

        Utility.mFacebook = new Facebook(APP_ID);
        Utility.mAsyncRunner = new AsyncFacebookRunner(Utility.mFacebook);
        SessionStore.restore(Utility.mFacebook, this);
        SessionEvents.addAuthListener(new FbAPIsAuthListener());
        SessionEvents.addLogoutListener(new FbAPIsLogoutListener());
        mLoginButton = (LoginButton) findViewById(R.id.login);
        mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions);
        if (Utility.mFacebook.isSessionValid()) {
            mLoginButton.setVisibility(View.INVISIBLE);
        }        
}

public void onClick(View v) {
        switch(v.getId())
        {           
            case R.id.btnFacebookShare:
                if (!Utility.mFacebook.isSessionValid()) {
                    Utility.mFacebook.authorize(PhotoPage.this , permissions, AUTHORIZE_ACTIVITY_RESULT_CODE, new LoginDialogListener());
                }
                else 
                {                   
                    Bundle bCreateAlbum = new Bundle();
                        bCreateAlbum.putString("message", "");
                        bCreateAlbum.putString("name", getString(R.string.photo_AlbumName));                    
                        Utility.mAsyncRunner.request("me/albums", bCreateAlbum, "POST", new CreateAlbumsListener(), null);
                }
                break;
            default:
                break;
        }
    }