我需要将我的Android应用程序安装请求发送给用户的朋友。这是我在网上找到的示例代码。这里的一切都很棒,我可以选择用户然后当我按下发送按钮时,Toast显示“请求已发送”。但我无法看到我发送请求的个人资料请求。这有什么不对?
public class InviteFriends extends Activity {
Activity activity = this;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
sendRequestDialog();
}
private void sendRequestDialog() {
Bundle params = new Bundle();
params.putString("message", "Learn how to make your Android apps social");
params.putString("frictionless", "1");
WebDialog requestsDialog = (
new WebDialog.RequestsDialogBuilder(activity,
Session.getActiveSession(),
params))
.setOnCompleteListener(new WebDialog.OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
Toast.makeText(activity.getApplicationContext(),
"Request cancelled",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(activity.getApplicationContext(),
"Network Error",
Toast.LENGTH_SHORT).show();
}
} else {
final String requestId = values.getString("request");
if (requestId != null) {
Toast.makeText(activity.getApplicationContext(),
"Request sent",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(activity.getApplicationContext(),
"Request cancelled",
Toast.LENGTH_SHORT).show();
}
}
}
})
.build();
requestsDialog.show();
}
}
答案 0 :(得分:1)
我发现了我的问题,
这是关键点: Facebook SDK v3.0 Request Dialog not sending application request
“从这个Facebook开发者页面:”用户到用户请求仅适用于Canvas应用程序“”
然后我搜索了我想要做的事情:
https://developers.facebook.com/docs/howtos/requests/#user_to_user
因此,我在Facebook开发者页面的仪表板设置中添加了新平台(Facebook上的应用程序)。就是这样,它现在正在运作..