我如何使用最新的Facebook SDK为Android分享的网页或链接 [英] How do I share a page or link using the latest Facebook SDK for Android

查看:180
本文介绍了我如何使用最新的Facebook SDK为Android分享的网页或链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让它集成了Facebook和Twitter的应用程序。
我已经开始实施的Facebook我的应用程序。
我已经成功地做​​到这一点使用最近发布的的Facebook SDK为Android例如

但现在我期待分享页面或使用相同的SDK来Facebook上的链接,但不知道如何做到这一点。

任何人都可以请让我知道如何做到这一点。我真的被困在此的很长一段时间。


解决方案

  @覆盖
    公共无效的onCreate(捆绑savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.photo);        Utility.mFacebook =新的Facebook(APP_ID);
        Utility.mAsyncRunner =新AsyncFacebookRunner(Utility.mFacebook);
        SessionStore.restore(Utility.mFacebook,这一点);
        SessionEvents.addAuthListener(新FbAPIsAuthListener());
        SessionEvents.addLogoutListener(新FbAPIsLogoutListener());
        mLoginButton =(LoginButton)findViewById(R.id.login);
        mLoginButton.init(这一点,AUTHORIZE_ACTIVITY_RESULT_ code,Utility.mFacebook,权限);
        如果(Utility.mFacebook.isSessionValid()){
            mLoginButton.setVisibility(View.INVISIBLE);
        }
}公共无效的onClick(视图v){
        开关(v.getId())
        {
            案例R.id.btnFacebookShare:
                如果(!Utility.mFacebook.isSessionValid()){
                    Utility.mFacebook.authorize(PhotoPage.this,权限,AUTHORIZE_ACTIVITY_RESULT_ code,新LoginDialogListener());
                }
                其他
                {
                    捆绑bCreateAlbum =新包();
                        bCreateAlbum.putString(消息,);
                        bCreateAlbum.putString(名,的getString(R.string.photo_AlbumName));
                        Utility.mAsyncRunner.request(ME /专辑,bCreateAlbum,POST,新CreateAlbumsListener(),NULL);
                }
                打破;
            默认:
                打破;
        }
    }

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.

解决方案

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

这篇关于我如何使用最新的Facebook SDK为Android分享的网页或链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆