我正在尝试遵循美味的教程,在newMeRequest
部分,请求永远不会返回,代码如示例所示,如下所示。我错过了什么吗?感谢?
private void makeMeRequest(final Session session) {
// Make an API call to get user data and define a
// new callback to handle the response.
Request request = Request.newMeRequest(session,
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// If the response is successful
if (BuildConfig.DEBUG){
Log.i(TAG, "GraphUserCallback" + user.getId()+" " + response.toString());
}
if (session == Session.getActiveSession()) {
if (user != null) {
// Set the id for the ProfilePictureView
// view that in turn displays the profile picture.
//profilePictureView.setProfileId(user.getId());
profilePictureView.setId(Integer.parseInt(user.getId()));
// Set the Textview's text to the user's name.
userNameView.setText(user.getName());
}
}
if (response.getError() != null) {
// Handle errors, will do so later.
}
}
});
request.executeAsync();
}
答案 0 :(得分:3)
确保添加此权限
<uses-permission android:name="android.permission.INTERNET"/>