2017-10-21 144 views
1

我在我的应用程序中有一个Fb登录,共享和类似按钮。所有的都是来自facebook sdk的小部件。所以默认情况下他们有facebook sdk的属性。当用户想分享或喜欢,(虽然没有登录),它会要求登录。那么该动作将被执行。我遵循教程https://developers.facebook.comAndroid Facebook SDK按钮呈灰色(不可点击)

其工作正常,用于登录和分享按钮,但像按钮灰显(不可点击)。任何帮助来解决这个问题。

public class MainActivity extends AppCompatActivity implements View.OnClickListener { 
    private ImageButton playBtn, someBtn; 
    LoginButton loginButton; 
    LikeView likeViewButton; 
    ShareButton shareButton; 
    ShareLinkContent linkContent; 
    CallbackManager callbackManager; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     initInstances(); 
     initCallbackManager(); 

     shareButton = (ShareButton)findViewById(R.id.share_button); 
     linkContent = new ShareLinkContent.Builder().setContentUrl(Uri.parse("https://developers.facebook.com")).build(); 
     shareButton.setShareContent(linkContent); 

     likeViewButton = (LikeView) findViewById(R.id.likeView_button); 
     likeViewButton.setObjectIdAndType("http://inthecheesefactory.com/blog/understand-android-activty-launchmode/en", LikeView.ObjectType.PAGE); 
    } 

    private void initInstances() { 
     playBtn = (ImageButton) findViewById(R.id.playBtn); 
     playBtn.setOnClickListener(this); 

     someBtn = (ImageButton) findViewById(R.id.someBtn); 
     someBtn.setOnClickListener(this); 

     loginButton = (LoginButton) findViewById(R.id.login_button); 
     loginButton.setReadPermissions("public_profile"); 
    } 

    private void initCallbackManager() { 
     callbackManager = CallbackManager.Factory.create(); 
     loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { 
      @Override 
      public void onSuccess(LoginResult loginResult) { 
       Log.d("Getting User Details", "Success"); 
       getUserDetails(loginResult); 
      } 

      @Override 
      public void onCancel() { 
       Log.d("LOGIN_CANCEL", "Cancel"); 
      } 

      @Override 
      public void onError(FacebookException error) { 
       Log.d("LOGIN_ERROR", "Error"); 
      } 
     }); 
    } 
} 
+0

我面临同样的问题 – Swapnil

+0

最早推出是灰色的,之后它是可点击的。 idk y? –

回答

0

Facebook将不再支持Native Like按钮。从Facebook blog post

本机像按钮:从移动应用程序设计的本机像按钮,将不再受支持从Facebook SDK版本4.28和以上开始。先前版本的SDK仍然可以使用Native Like按钮,但从2/6开始,Native Like按钮将不再受支持。在2/6之后,Native Like的对话框将不再出现,并且点击任何原生类似的按钮将不会导致任何操作。

0

如果你真的需要像查看刚刚写这篇文章的build.gradle(APP),但你不会有Facebook的SDK的更新了

implementation 'com.facebook.android:facebook-android-sdk:4.27.0'