java.lang.RuntimeException的:不提供结果ResultInfo同时使用Facebook的登录 [英] java.lang.RuntimeException: Failure delivering result ResultInfo while logging using Facebook

查看:2497
本文介绍了java.lang.RuntimeException的:不提供结果ResultInfo同时使用Facebook的登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序工作正常的模拟器。所以,我决定在我的Andr​​oid手机上运行我的应用程序。我试图登录到使用我的应用程序的Facebook帐户,它工作正常的模拟器。而当我跑我的android手机的应用程序,我总是得到这个例外 -

My application is working fine on emulator. So I decided to run my application on my Android phone. I am trying to login to Facebook account using my application and it works fine on emulator. And as soon as I run my application on android phone I always get this exception-

01-30 11:06:08.400: E/AndroidRuntime(7463): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=0, data=null} to activity {com.facebook.samples.sessionlogin/com.facebook.LoginActivity}: java.lang.NullPointerException

下面是我的code -

Below is my code-

 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment, container, false);

    buttonLoginLogout = (Button) view.findViewById(R.id.buttonLoginLogout);
    textInstructionsOrLink = (TextView) view.findViewById(R.id.instructionsOrLink);

    Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

    Session session = Session.getActiveSession();
    if (session == null) {
        if (savedInstanceState != null) {
        session = Session.restoreSession(getActivity(), null, statusCallback,
            savedInstanceState);
        }
        if (session == null) {
        session = new Session(getActivity());
        }
        Session.setActiveSession(session);
        if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
        session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
        }
    }

    updateView();

    return view;
    }

    @Override
    public void onStart() {
    super.onStart();
    Session.getActiveSession().addCallback(statusCallback);
    }

    @Override
    public void onStop() {
    super.onStop();
    Session.getActiveSession().removeCallback(statusCallback);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Session.getActiveSession().onActivityResult(getActivity(), requestCode, resultCode, data);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Session session = Session.getActiveSession();
    Session.saveSession(session, outState);
    }

    private void updateView() {
    Session session = Session.getActiveSession();
    if (session.isOpened()) {

        Intent thesisProject = new Intent(getActivity(), ThesisProjectAndroid.class);
        startActivity(thesisProject);

    } else {
        Log.d(TAG_LOGIN_FAILED,
            "There is something wrong with your Facebook account. Please try again.");

        textInstructionsOrLink.setText(R.string.instructions);
        buttonLoginLogout.setText(R.string.login);
        buttonLoginLogout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onClickLogin();
        }
        });
    }
    }


    private void onClickLogin() {
    Session session = Session.getActiveSession();
    if (!session.isOpened() && !session.isClosed()) {
        session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
    } else {
        Session.openActiveSession(getActivity(), this, true, statusCallback);
    }
    }

    private void onClickLogout() {
    Session session = Session.getActiveSession();
    if (!session.isClosed()) {
        session.closeAndClearTokenInformation();
    }
    }

    private class SessionStatusCallback implements Session.StatusCallback {
    @Override
    public void call(Session session, SessionState state, Exception exception) {
        updateView();
    }
    }

我在做什么是 - 当我登录使用Facebook帐户,我需要去另外一个意图,因为我安装在Android手机上这个应用程序(这是工作在模拟器罚款),但只要,我总是获得登录失败为应用程序启动时,甚至没有我所提供的用户名和密码Facebook登录页面上,也是我得到了上面的异常,尽快。

What I am doing is- As soon as I am logged in using Facebook account, I need to go to another Intent (which is working fine in emulator) but as soon as I installed this application in the android phone, I always gets Login failed as soon as application is started without even I have provided the username and password on the facebook login page and also I get the above exception.

和还任何人都可以让我知道我的逻辑是正确的的UpdateView方法的身分─我想要做的是,只要Facebook的身份验证是正确的手段我我能够登录,然后我需要去另一个意图。

And also can anyone let me know my logic is right in the updateView method or not- What I wanted to do is, as soon as Facebook authentication is correct means I am able to login, then I need to go to another Intent.

谁能帮我在这里为什么这种事情发生?

Can anyone help me out here why this things is happening?

推荐答案

坦克你@马特Accola。 该网页这样说:

Tank you @Matt Accola. that page say this:

在不保留活动的开发选项打开了在Android系统设置Facebook的SSO登录过程中被打破。该LoginActivity反复调用,每次LoginActivity的一个实例被泄漏。登录从来没有真正完成,这个过程最终需要被杀死。

When the "Don't keep activities" developer option is turned on in the Android system settings the Facebook SSO login process is broken. The LoginActivity is called repeatedly and each time an instance of LoginActivity is leaked. The login never actually completes and the process eventually needs to be killed.

请注意,这个错误是不可复制的,如果不保留活动设置是关闭的。

Please note this bug is not reproducible if the "Don't keep activities" settings is turned off.

请注意,如果所有用户帐户都记录了原生的Facebook应用程序的这个bug只是重复的。

Please note this bug is only reproducible if all user accounts are logged out of the native Facebook app.

重现步骤: 1.启用不保留活动,在Android开发期权设备设置(设置下)。

Steps to Reproduce: 1. Enable "Don't keep activities" setting in Android Developer Options (under Settings) on device.

确认原生的Facebook应用程序为Android安装在设备上。

  1. Verify native Facebook app for Android is installed on device.

请确保所有用户帐户都记录了原生的Facebook应用程序的。

Make sure all user accounts are logged out of the native Facebook app.

下载Facebook的SDK的Andr​​oid源$ C ​​$ c和样本并导入项目到Eclipse中。

Download the Facebook SDK for Android source code and samples and import the projects into Eclipse.

启动HelloFacebookSample。

Launch the HelloFacebookSample.

点击登录按钮。 Facebook的登录屏幕应该显示出来。

Tap the Log In button. The Facebook login screen should be displayed.

输入Facebook的凭据,然后点击登录按钮。经过等待可能出现的身份验证对话框。

Enter Facebook credentials and tap Log In button. After a wait the auth dialog may appear.

点击身份验证对话框就OK了。

Tap OK on the auth dialog.

预期的行为: 登录过程应完成和HelloFacebookSample屏幕应该显示在登录状态。

Expected Behavior: The login process should complete and the HelloFacebookSample screen should be displayed in the logged in state.

实际行为: Facebook的屏幕仍然与进度对话框可见。整个系统变慢,最终处理开始崩溃的内存不足。在这个过程中我已经抓获了堆转储,可以看到LoginActivity的已经泄露无数实例。同时使StrictMode会显示消息,指出LoginActivity实例被泄露。

Actual Behavior: The Facebook screen remains visible with the progress dialog. The entire system slows down and eventually processes start crashing as memory runs short. I have captured a heap dump during this process and can see numerous instances of LoginActivity which have been leaked. Also enabling StrictMode will show messages stating LoginActivity instances are being leaked.

这篇关于java.lang.RuntimeException的:不提供结果ResultInfo同时使用Facebook的登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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