0

我浏览了教程并成功实现了登录和注销流程。但是,这适用于内置登录按钮:

  <com.facebook.widget.LoginButton
        android:id="@+id/authButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp"
        />

当用户选择例如。列表中的项目,将出现一个带有共享选项的自定义对话框。当用户选择此共享选项时,我想将他们登录到 facebook,并且通常的东西,例如 ABC 想访问您的个人资料,ABC 想发布给您的朋友等。

编辑:我想我已经找到了我需要的东西,但是我很早就遇到了问题。我无法导入FacebookDialog. 既不提供给我,我导入时也不能使用com.facebook.*;

根据 FacebookDialog是在com.facebook.widget包中。但是,当我键入import com.facebook.widget. 提供的唯一对话框是WebDialog.

4

1 回答 1

0

我需要的是Feed 对话框

例子:

private void publishFeedDialog() {
    Bundle params = new Bundle();
    params.putString("name", "New level!");
    params.putString("description", "I have reached level " + lvel!");
    params.putString("link", "https://play.google.com/store/apps/details?id=com.myapp");
    params.putString("picture", "http://myapp.com/Images/icoon.png");

        WebDialog feedDialog = (
                new WebDialog.FeedDialogBuilder(this,
                    Session.getActiveSession(),
                    params))
                .setOnCompleteListener(new OnCompleteListener() {

                    @Override
                    public void onComplete(Bundle values,
                        FacebookException error) {
                         if (error == null) {
                                // When the story is posted, echo the success
                                // and the post Id.
                                final String postId = values.getString("post_id");
                                if (postId != null) {
                                    //Toast.makeText(getActivity(), "Posted story, id: "+postId, Toast.LENGTH_SHORT).show();
                                } else {
                                    // User clicked the Cancel button
                                    //Toast.makeText(getActivity().getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                                }
                            } else if (error instanceof FacebookOperationCanceledException) {
                                // User clicked the "x" button
                                //Toast.makeText(getActivity().getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                            } else {
                                // Generic, ex: network error
                                Toast.makeText(getApplicationContext(), 
                                    "Error sharing app",  Toast.LENGTH_SHORT).show();
                            }
                    }

                })
                .build();
            feedDialog.show();
}
于 2013-09-11T22:09:39.203 回答