我在我的应用程序中使用 Facebook SDK(最新版本)。我只想从登录用户那里获取一般数据,例如姓名、出生日期、位置、性别等,并且只想相应地填写详细信息。但问题是它一次又一次地无限显示权限对话框,即使我为应用程序权限对话框按下确定或取消,它也会一次又一次地显示该权限对话框。我无法理解这有什么问题。
我的登录功能是这样的:-
Session.openActiveSession(context, true, new Session.StatusCallback() {
@Override
public void call(final Session session, SessionState state, Exception exception) {
// TODO Auto-generated method stub
if(session.isOpened())
{
Toast.makeText(context, "Please Wait", 1).show();
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(context, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
}
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// TODO Auto-generated method stub
if(user!=null)
{
try{
Log.d("", "Fb responcse == "+response.toString());
Log.d("", "FbUser >> "+ user.toString());
fbUserid=user.getId();
fbAccessToken=session.getAccessToken();
Log.i("User Name ", "FbName : "+user.getName());
Log.i("User Id ", "FbId : "+user.getId());
Log.i("User Id ", "FbLocation : "+user.getLocation().toString());
Log.i("User Id ", "FbEmailId : "+user.getLink());
Log.i("User Id ", "FbDob : "+user.getBirthday());
Log.i("User Id ", "FbGender : "+user.asMap().get("gender").toString());
Log.i("User Id ", "FbEmail : "+user.getProperty("email").toString());
//Log.i("User Id ", "FbCity : "+user.getLocation().getCity().toString());
//Log.i("User Id ", "FbState : "+user.getLocation().getState().toString());
Log.i("User Access Token ", "FbAccess Token : "+session.getAccessToken());
pBar.setVisibility(View.INVISIBLE);
String name = user.getName();
String dob = user.getBirthday();
String gender = user.asMap().get("gender").toString();
String email =user.getProperty("email").toString();
String city = user.getLocation().getProperty("name").toString();
String url="http://graph.facebook.com/"+user.getId()+"/picture?type=large";
setText(name, dob, email, city, "","",url);
}catch(Exception ex){
ex.printStackTrace();
}
}
else{
pBar.setVisibility(View.INVISIBLE);
Log.i("ELSE", "ELSE");
}
}
});
}
}
});
此外,我正在使用此代码片段获取这些详细信息的权限:-
List<String> PERMISSIONS = Arrays.asList("publish_actions","email","user_birthday","user_location");
请帮我解决这个问题,因为它一次又一次地向我显示权限对话框。
任何帮助将不胜感激提前感谢