创建一个方法:
getProfileInformation()
在方法主体中,您必须编写:
public void getProfileInformation() {mAsyncRunner.request("me", new RequestListener() { @Override public void onComplete(String response, Object state) { Log.d("Profile", response); String json = response; try { JSonObject profile = new JSonObject(json); // getting name of the user String name = profile.getString("name"); // getting email of the user String email = profile.getString("email"); //getting user birthday String birth_day=profile.getString("birthday"); runonUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), "Name: " + name + "nEmail: " + email, Toast.LENGTH_LONG).show(); } }); } catch (JSonException e) { e.printStackTrace(); } } @Override public void onIOException(IOException e, Object state) { } @Override public void onFileNotFoundException(FileNotFoundException e, Object state) { } @Override public void onMalformedURLException(MalformedURLException e, Object state) { } @Override public void onFacebookError(FacebookError e, Object state) { }});}
上面的函数将从facebook获取json数据。您需要解析json以获得单独的配置文件数据。
来自Facebook的样本配置文件json将如下所示:
{ "id": "1464730016", "name": "XYZ", "first_name": "XYZ", "last_name": "ABC", "link": "https://....", "username": "XYZ", "birthday": "22/10/89", "hometown": }有关更多详细信息,请参阅:
http://www.androidhive.info/2012/03/android-facebook-connect-tutorial/



