0
我想用我自己的按鈕登錄Facebook SDK 4.3,但我遇到了一些問題。這裏是我的代碼如何使用我自己的按鈕登錄Facebook SDK 4.3?
public class MainActivity extends Activity {
CallbackManager callbackManager;
ShareDialog shareDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
callbackManager = CallbackManager.Factory.create();
Button bt= (Button)findViewById(R.id.button1);
shareDialog = new ShareDialog(this);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
openFB();
}
});
}
public void openFB() {
//Login Callback registration
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Toast.makeText(getApplicationContext(), "in LoginResult on success", Toast.LENGTH_LONG).show();
//Login success - process to Post
if (ShareDialog.canShow(ShareLinkContent.class)) {
String description = "description";
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("title")
.setContentDescription(description)
.setContentUrl(Uri.parse("http://google.com"))
.setImageUrl(Uri.parse("http://google.com"))
.build();
shareDialog.show(linkContent, ShareDialog.Mode.FEED);
}
}
@Override
public void onCancel() {
Toast.makeText(getApplicationContext(), "in LoginResult on cancel", Toast.LENGTH_LONG).show();
}
@Override
public void onError(FacebookException exception) {
Toast.makeText(getApplicationContext(), "in LoginResult on error", Toast.LENGTH_LONG).show();
}
});
LoginManager.getInstance().logInWithReadPermissions(this, "user_friends"); //Log in to FB
}
}
我得到這個錯誤在最後一行:
的方法logInWithReadPermissions(片段集合)在 類型LoginManager不適用於參數 (MainActivity,字符串)
正如你所知有另一個logInWithReadPermissions方法與2參數是(活動,集合),但我不知道我得到這個錯誤。請幫我解決這個問題!