我正在尝试从 Android SDK for Facebook 发送好友请求。我有机会问了一位 Facebook 工程师,他说 Android 目前不支持好友请求。所以我想我被困在将用户重定向到浏览器上。我的问题是我该怎么做?到目前为止,这是我的代码:(它不起作用)
private void sendRequestDialog()
{
String USER_ID = "stack.overflow.123";
Bundle params = new Bundle();
params.putString("id", USER_ID);
WebDialog requestsDialog = (
new WebDialog.RequestsDialogBuilder(getActivity(),
Session.getActiveSession(),
params))
.setOnCompleteListener(new OnCompleteListener()
{
@Override
public void onComplete(Bundle values, FacebookException error)
{
if(error != null)
{
if(error instanceof FacebookOperationCanceledException)
{
Toast.makeText(getActivity().getApplicationContext(), "Request cancelled", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getActivity().getApplicationContext(), "Network Error", Toast.LENGTH_SHORT).show();
}
}
else
{
final String requestId = values.getString("request");
if (requestId != null)
{
Toast.makeText(getActivity().getApplicationContext(), "Request sent", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(getActivity().getApplicationContext(), "Request cancelled", Toast.LENGTH_SHORT).show();
}
}
}
})
.build();
requestsDialog.show();
}