Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取Facebook用户信息并从中为Android SDK创建配置文件_Android_Facebook_Userinfo - Fatal编程技术网

获取Facebook用户信息并从中为Android SDK创建配置文件

获取Facebook用户信息并从中为Android SDK创建配置文件,android,facebook,userinfo,Android,Facebook,Userinfo,我希望我的facebook登录按钮能够自动获取用户的facebook信息,并从中创建个人资料 我已经看过facebook提供的示例,但我不想在LinearLayout中创建单独的片段。我只想把它应用到我的亲戚朋友身上 有人能告诉我该怎么做吗?我到处搜索,找到了不推荐的答案,我对Facebook API是新手:/ 我需要创建什么方法来获取用户的信息,然后将该信息发送到第二个活动类? 以下是我到目前为止编写的一些代码: package com.example.app; import com.fac

我希望我的facebook登录按钮能够自动获取用户的facebook信息,并从中创建个人资料

我已经看过facebook提供的示例,但我不想在LinearLayout中创建单独的片段。我只想把它应用到我的亲戚朋友身上

有人能告诉我该怎么做吗?我到处搜索,找到了不推荐的答案,我对Facebook API是新手:/

我需要创建什么方法来获取用户的信息,然后将该信息发送到第二个活动类?

以下是我到目前为止编写的一些代码:

package com.example.app;

import com.facebook.*;
import com.facebook.model.GraphUser;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class MainActivity extends Activity {    

@Override
/*
 * called when activity is first created
 */
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

/*
 * Create API call to facebook to grab user data and define a 
 * new callback to handle the response
 */
public void GrabFbUserInfo(View view){


    //Request call
    Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {

        @Override
        public void onCompleted(GraphUser user, Response response) {
            //If the response is successful
            if (session == Session.)

        }
    });

}

}
以下是包含在RelativeLayout中的activity_main的XML:

<com.facebook.widget.LoginButton
    android:id="@+id/fb_login_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="76dp"
    android:contentDescription="@string/loginButton"
    facebook:confirm_logout="false"
    facebook:fetch_user_info="true" />

谢谢你的建议

请尝试我的库:

有了它的帮助,这真的很容易

mSocialNetworkManager.getFacebookSocialNetwork().requestLogin(new OnLoginCompleteListener() {
    @Override
    public void onLoginSuccess(int socialNetworkID) {
        mSocialNetworkManager.getFacebookSocialNetwork().requestCurrentSocialPerson();
    }

    @Override
    public void onError(int socialNetworkID, String requestID, String errorMessage, Object data) {

    }
});

查看自述了解更多信息,如果您有任何问题,请告诉我。

请关注我的帖子Hi Anton,首先是精彩的作品。第二,我对android编程相当陌生,我如何将您的库添加到我现有的项目中?这类似于将facebook SDK添加到我现有的项目中吗?@AndyRoid,您好,请遵循以下步骤