private static PermissionsPair handlePermissionResponse(GraphResponse response){
  if (response.getError() != null) {
    return null;
  }
  JSONObject result=response.getJSONObject();
  if (result == null) {
    return null;
  }
  JSONArray data=result.optJSONArray("data");
  if (data == null || data.length() == 0) {
    return null;
  }
  List<String> grantedPermissions=new ArrayList<String>(data.length());
  List<String> declinedPermissions=new ArrayList<String>(data.length());
  for (int i=0; i < data.length(); ++i) {
    JSONObject object=data.optJSONObject(i);
    String permission=object.optString("permission");
    if (permission == null || permission.equals("installed")) {
      continue;
    }
    String status=object.optString("status");
    if (status == null) {
      continue;
    }
    if (status.equals("granted")) {
      grantedPermissions.add(permission);
    }
 else     if (status.equals("declined")) {
      declinedPermissions.add(permission);
    }
  }
  return new PermissionsPair(grantedPermissions,declinedPermissions);
}

private static PermissionsPair handlePermissionResponse ( GraphResponse response ) { if ( response . getError ( ) != null ) { return null ; } JSONObject result = response . getJSONObject ( ) ; if ( result == null ) { return null ; } JSONArray data = result . optJSONArray ( "data" ) ; if ( data == null || data . length ( ) == 0 ) { return null ; } List < String > grantedPermissions = new ArrayList < String > ( data . length ( ) ) ; List < String > declinedPermissions = new ArrayList < String > ( data . length ( ) ) ; for ( int i = 0 ; i < data . length ( ) ; ++ i ) { JSONObject object = data . optJSONObject ( i ) ; String permission = object . optString ( "permission" ) ; if ( permission == null || permission . equals ( "installed" ) ) { continue ; } String status = object . optString ( "status" ) ; if ( status == null ) { continue ; } if ( status . equals ( "granted" ) ) { grantedPermissions . add ( permission ) ; } else if ( status . equals ( "declined" ) ) { declinedPermissions . add ( permission ) ; } } return new PermissionsPair ( grantedPermissions , declinedPermissions ) ; }
this parses a server response to a call to me / permissions . it will return the list of granted permissions . it will optionally update an access token with the requested permissions .
