Facebook Android SDK 4.4在登录期间抛出异常

时间:2015-08-07 04:19:31

标签: android facebook facebook-android-sdk android-facebook

我的登录工作正常,然后这些异常开始被Facebook SDK抛出,导致我的应用程序崩溃。

例外1

08-06 23:35:15.672    1916-2845/com.facebook.katana W/MessageQueue﹕ Handler (android.os.Handler) {1b573833} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (android.os.Handler) {1b573833} sending message to a Handler on a dead thread
        at android.os.MessageQueue.enqueueMessage(MessageQueue.java:325)
        at android.os.Handler.enqueueMessage(Handler.java:631)
        at android.os.Handler.sendMessageAtTime(Handler.java:600)
        at android.os.Handler.sendMessageDelayed(Handler.java:570)
        at android.os.Handler.post(Handler.java:326)
        at com.facebook.tools.dextr.runtime.detour.HandlerDetour.a(HandlerDetour.java:38)
        at com.facebook.fbservice.ops.DefaultBlueServiceOperation.a(DefaultBlueServiceOperation.java:846)
        at com.facebook.fbservice.ops.DefaultBlueServiceOperation.b(DefaultBlueServiceOperation.java:746)
        at com.facebook.fbservice.ops.DefaultBlueServiceOperation$3.b(DefaultBlueServiceOperation.java:691)
        at com.facebook.fbservice.service.BlueServiceQueue.a(BlueServiceQueue.java:598)
        at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:417)
        at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:59)
        at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:304)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:60)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.os.HandlerThread.run(HandlerThread.java:61)

例外2

08-06 23:37:36.823    1916-4440/com.facebook.katana W/fb4a(:<default>):BlueServiceQueue﹕ Exception during service
org.apache.http.NoHttpResponseException: The target server failed to respond
        at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:85)
        at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174)
        at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180)
        at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
        at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
        at com.facebook.http.common.executorimpl.apache.FbHttpClientImpl.execute(FbHttpClientImpl.java:157)
        at com.facebook.http.common.executorimpl.apache.FbHttpClientImpl.execute(FbHttpClientImpl.java:145)
        at com.facebook.http.common.executorimpl.apache.FbHttpClientRequestExecutor.a(FbHttpClientRequestExecutor.java:63)
        at com.facebook.http.executors.qebased.QeHttpRequestExecutor.a(QeHttpRequestExecutor.java:102)
        at com.facebook.tools.dextr.runtime.detour.HttpRequestExecutorDetour.a(HttpRequestExecutorDetour.java:53)
        at com.facebook.http.common.RequestFlowStateController.a(RequestFlowStateController.java:110)
        at com.facebook.http.common.FbRedirectController.a(FbRedirectController.java:100)
        at com.facebook.http.common.FbHttpRequestProcessor.c(FbHttpRequestProcessor.java:389)
        at com.facebook.http.common.FbHttpRequestProcessor.b(FbHttpRequestProcessor.java:357)
        at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:344)
        at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:274)
        at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:1240)
        at com.facebook.http.common.FbHttpRequestProcessor$Dispatcher.run(FbHttpRequestProcessor.java:1261)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
        at com.facebook.common.executors.WrappingExecutorService$1.run(WrappingExecutorService.java:77)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at com.facebook.common.executors.DefaultConstrainedListeningExecutorService$Worker.run(DefaultConstrainedListeningExecutorService.java:310)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at com.facebook.common.executors.NamedThreadFactory$1.run(NamedThreadFactory.java:42)
        at java.lang.Thread.run(Thread.java:818)

我使用SDK的代码

    FacebookSdk.sdkInitialize(getApplicationContext());

    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager, this);

    dialog = new MaterialDialog.Builder(this)
            .title(getString(R.string.authenticate))
            .content(getString(R.string.please_wait))
            .cancelable(false)
            .progress(true, 0).build();
}

@OnClick(R.id.login_button)
public void facebookLogin() {
    if (Utils.Operations.isOnline(this)) {
        LoginManager.getInstance().logInWithReadPermissions(this, permissionsNeeded);
    } else {
        Toast.makeText(LoginActivity.this, getString(R.string.no_connection),Toast.LENGTH_SHORT).show();
    }
}


@Override
public void onSuccess(Object o) {
    Log.v("alarm","SUCCESs triggered");
    final LoginResult loginResult = (LoginResult) o;

    GraphRequest.newMeRequest(
            loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(JSONObject json, GraphResponse response) {
                    if (response.getError() != null) {
                        Log.v("alarm", "OnComplete triggered");
                    } else {

1 个答案:

答案 0 :(得分:0)

发生错误是因为我在清单中将noHistory="true"添加到了我的登录活动标签中。在完成此操作后,处理登录的FacebookActivity无法与启动登录操作的活动进行通信,从而导致崩溃。要从历史记录中删除活动,我只需在启动意图导航到主要活动时使用相应的标记。