1

I have the similar problem as Android Facebook.authorize don't call oncomplete method

onComplete method isn`t called after authorization in Facebook (both when Facebook app is installed or not).

Activity class

package com.greatapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.facebook.android.*;
import com.facebook.android.Facebook.*;

public class MyGreatAppActivity extends Activity {

Facebook facebook = new Facebook("YOUR_APP_ID");

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

    facebook.authorize(this, new Facebook.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) {
    super.onActivityResult(requestCode, resultCode, data);

    facebook.authorizeCallback(requestCode, resultCode, data);
}
}

As You see from code, i`ve implemented onActivityResult as it was shown in official guide http://developers.facebook.com/docs/mobile/android/sso/

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.greatapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".MyGreatAppActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

And there is no android:noHistory flag in manifest file.

The only error i've found in log

 Activity com.greatapp.MyGreatActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44e8c518 that was originally added here
android.view.WindowLeaked: Activity com.greatapp.MyGreatActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44e8c518 that was originally added here
at android.view.ViewRoot.<init>(ViewRoot.java:227)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:424)
at android.app.Dialog.show(Dialog.java:239)
at com.facebook.android.Facebook.dialog(Facebook.java:814)
at com.facebook.android.Facebook.startDialogAuth(Facebook.java:343)
at com.facebook.android.Facebook.authorize(Facebook.java:206)
at com.facebook.android.Facebook.authorize(Facebook.java:114)
at com.greatapp.MyGreatActivity.onCreate(MyGreatActivity.java:18)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)

I've tried android 2.1, 2.2 and 4.0.3 and have the same issue.

Copying classes from example from Facebook sdk also didn't work.

Please provide any possible help. Thanks in advance!

Community
  • 1
  • 1
user898722
  • 139
  • 1
  • 9
  • Weird, that (usually) means that the activity was closed, you can read these threads: [Activity has leaked window](http://stackoverflow.com/questions/7252086/activity-has-leaked-window) and [Activity has leaked window that was originally added](http://stackoverflow.com/questions/2850573/activity-has-leaked-window-that-was-originally-added) – Nitzan Tomer Apr 19 '12 at 19:07

1 Answers1

1

There's an issue with the Facebook Android SSO, it even says so in the Platform Status.

You can get more info at this bug report: https://developers.facebook.com/bugs/385350798163367

Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
  • Actually i don`t get this error, there is no such record in logs. Android just stays on facebook page instead of returning to application. – user898722 Apr 19 '12 at 16:26
  • You're code looks fine to me. How are you sure that the *onComplete* is not called? there's nothing in that method, or are you debugging? The bug report is for a specific one, but facebook writes in the platform status "We are working on a fix for the Android SSO errors" (notice the plural form), and so I think it's safe to assume that it might be somehow related. Are you running this with an emulator? If so, you can run a network sniffer and see what happens in the background. – Nitzan Tomer Apr 19 '12 at 16:42
  • Yep, i`m debugging on external device. I've figured out, that example that came with facebook android sdk has the same issue. I've found an error in logs and updated the question. – user898722 Apr 19 '12 at 18:54