How do I share a page or link using the latest Facebook SDK for Android

允我心安 提交于 2020-01-03 05:19:06

问题


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;
        }
    } 


来源:https://stackoverflow.com/questions/8878920/how-do-i-share-a-page-or-link-using-the-latest-facebook-sdk-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!