使用facebook.authorize了Android SDK不叫onActivityResult [英] Using facebook.authorize with the Android SDK does not call onActivityResult

查看:133
本文介绍了使用facebook.authorize了Android SDK不叫onActivityResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的Andr​​oid的活动叫Facebook的授权,但由于某种原因它永远不会调用onActivityResult,因为它应该。

我跟着href="https://developers.facebook.com/docs/mobile/android/build/" rel="nofollow">官方教程的

 公共类SimpleFacebookActivity延伸活动{
    私人的EditText控制台;
    私人商标=新的Facebook(APP_ID);

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);

        this.console =(EditText上)super.findViewById(R.id.console);
        this.console.append(开始\ñ\ N);

        字符串文本= Integer.toString(super.getIntent()getFlags()及。Intent.FLAG_ACTIVITY_NO_HISTORY);
        this.console.append(文本);

        this.facebook.authorize(这一点,新DialogListener(){
            @覆盖
            公共无效的onComplete(束值){}

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

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

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

    @覆盖
    公共无效onActivityResult(INT申请code,INT结果code,意图数据){
        this.console.append(onActivityResult,请求code:+请求code +\ñ\ N);
        super.onActivityResult(要求code,因此code,数据);
        this.facebook.authorizeCallback(要求code,因此code,数据);

    }
}
 

我添加了一个文本编辑窗口小部件,而我登录,当我运行该应用程序我得到的是:

 入门

0
 

我检查,看看是否FLAG_ACTIVITY_NO_HISTORY设置,因为提到它的教程,并在另一篇文章中,我看到这里的堆叠式和NBSP;溢出,但对我来说它没有集中,因此不能成为问题。

我怎样才能解决这个问题呢?

解决方案

我想这是因为你需要一些键添加到您的应用程序在Facebook的:

https://developers.facebook.com/docs/mobile/android /构建/#SIG

但关键的时候,你跟着一步一步的指导,所以你得检查Facebook的SDK的调试器,为你扔一个错误,告诉像您所使用的关键不在于没有正确创建同您的应用程序,复制粘贴,瞧!

I'm trying to call the Facebook authorization from my Android activity, but for some reason it never calls the onActivityResult as it should.

I followed the official tutorial, and I even created a very simple application just in order to try this functionality:

public class SimpleFacebookActivity extends Activity {
    private EditText console;
    private Facebook facebook = new Facebook(APP_ID);

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        this.console = (EditText)super.findViewById(R.id.console);
        this.console.append("Started\n\n");

        String text = Integer.toString(super.getIntent().getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY);
        this.console.append(text);

        this.facebook.authorize(this, new DialogListener() {
            @Override
            public void onComplete(Bundle values) {}

            @Override
            public void onFacebookError(FacebookError error) {}

            @Override
            public void onError(DialogError e) {}

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

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        this.console.append("onActivityResult, request code: " + requestCode + "\n\n");
        super.onActivityResult(requestCode, resultCode, data);
        this.facebook.authorizeCallback(requestCode, resultCode, data);

    }
}

I added a TextEdit widget to which I log, and when I run this application all I get is:

Started

0

I checked to see if the FLAG_ACTIVITY_NO_HISTORY is set since they mention it in the tutorial and in another post I saw here on Stack Overflow, but in my case it's not set and so can't be the problem.

How can I fix this problem?

解决方案

I think this is because you need to add some key to your app in Facebook:

https://developers.facebook.com/docs/mobile/android/build/#sig

But the key is not correctly created when you follow the step-by-step guide, so you got to check for the debugger of the Facebook SDK, to throw you an error telling something like the key you are using is not the same of your app, copy paste and voila!

这篇关于使用facebook.authorize了Android SDK不叫onActivityResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆