且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过Facebook的Andr​​oid SDK的应用程序发送请求的朋友

更新时间:2023-10-11 21:42:46

Android SDK中具有的对话框,你可以用,当你打开一个对话框,您指定要打开的对话​​框。

您可以看到对话框文档中提供的对话框的列表中。 其中一个对话框是请求对话框,你可以打开从Android SDK为好,是这样的:

 商标=新的Facebook(YOUR_APP_ID);

....

捆绑PARAMS =新包();
params.putString(标题,邀请好友);
facebook.dialog(这一点,美联社prequests,PARAMS,新DialogListener(){
    @覆盖
    公共无效的onComplete(束值){}

    @覆盖
    公共无效onFacebookError(FacebookError错误){}

    @覆盖
    公共无效onerror的(DialogError E){}

    @覆盖
    公共无效OnCancel的(){}
});
 

您可以在此对话框中添加更多的参数,使用文档,看看有什么是你需要的。


修改

好吧,看看这个code:

 捆绑paramsOut =新包(),paramsIn = this.getIntent()getExtras()。
paramsOut.putString(信息,paramsIn.getString(信息));
this.facebook.dialog(这一点,美联社prequests,paramsOut,新InviteListener(本));
 

我用它,它很适合我,该应用程序的请求被发送,用户接收它。 由于您的code是类似pretty的,它是安全的假设,问题是什么是不同的,所以你应该张贴的code到有什么不同。

那么,什么是在鸭prequestsListener 的的你的吗?说这只是显示一个弹出不帮我帮你。 此外,这是什么* Hackbook?它是一个活动?

Currently I'm developing an Android app for that I'm using the Facebook SDK. It's working fine for posting messages to the wall etc., but through this SDK I'm unable to send an app request to others.

Can anyone help me out?

here is my code snippet:

Bundle params = new Bundle();
params.putString("message", getString(R.string.request_message));
Utility.mFacebook.dialog(Hackbook.this, "apprequests", params, new AppRequestsListener());

and AppRequestsListener:

public class AppRequestsListener extends BaseDialogListener {
    @Override
    public void onComplete(Bundle values) {
        Toast toast = Toast.makeText(getApplicationContext(), "App request sent", Toast.LENGTH_SHORT);
        toast.show();
    }

    @Override
    public void onFacebookError(FacebookError error) {
        Toast.makeText(getApplicationContext(), "Facebook Error: " + error.getMessage(), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onCancel() {
        Toast toast = Toast.makeText(getApplicationContext(), "App request cancelled", Toast.LENGTH_SHORT);
        toast.show();
    }
}

The android sdk has Dialogs which you can use, and when you open a dialog you specify which dialog you want to open.

You can see the list of available dialogs in the Dialogs documentation. One of the dialogs is the Requests Dialog and you can open that from the android sdk as well, something like:

Facebook facebook = new Facebook("YOUR_APP_ID");

....

Bundle params = new Bundle();
params.putString("title", "invite friends");
facebook.dialog(this, "apprequests", params, new DialogListener() {
    @Override
    public void onComplete(Bundle values) {}

    @Override
    public void onFacebookError(FacebookError error) {}

    @Override
    public void onError(DialogError e) {}

    @Override
    public void onCancel() {}
});

You can add more parameters for this dialog, use the documentation to see what it is you need.


Edit

Ok, check out this code:

Bundle paramsOut = new Bundle(), paramsIn = this.getIntent().getExtras();
paramsOut.putString("message", paramsIn.getString("message"));
this.facebook.dialog(this, "apprequests", paramsOut, new InviteListener(this));

I use it and it works well for me, the app request is being sent and the user receives it. Since your code is pretty similar, it is safe to assume that the problem is with what's different, and so you should post the code to what is different.

So, what's in that AppRequestsListener of yours? Saying that it just shows a popup does not help me to help you. Also, what is this *Hackbook"? is it an activity?