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

2023-09-04 07:22:56 作者:~美人泪*无人能懂~

目前我正在开发一个Android应用程序为我使用Facebook的SDK。它的正常工作张贴信息墙等,但通过此SDK我无法发送应用程序请求他人。

谁能帮我?

这是我的code片断:

 捆绑PARAMS =新包();
params.putString(信息,的getString(R.string.request_message));
Utility.mFacebook.dialog(Hackbook.this,美联社prequests,PARAMS,新鸭prequestsListener());
 

和鸭prequestsListener 的:

 公共类鸭prequestsListener延伸BaseDialogListener {
    @覆盖
    公共无效的onComplete(束值){
        吐司面包= Toast.makeText(getApplicationContext(),应用程序请求而发送,Toast.LENGTH_SHORT);
        toast.show();
    }

    @覆盖
    公共无效onFacebookError(FacebookError错误){
        Toast.makeText(getApplicationContext(),脸谱错误:+ error.getMessage(),Toast.LENGTH_SHORT).show();
    }

    @覆盖
    公共无效OnCancel的(){
        吐司面包= Toast.makeText(getApplicationContext(),应用程序请求取消,Toast.LENGTH_SHORT);
        toast.show();
    }
}
 

解决方案

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?

 
精彩推荐
图片推荐