我遇到与Android Facebook.authorize don't call oncomplete method
类似的问题onComplete方法在Facebook授权后不被调用(无论是否安装Facebook应用程序)。
活动类
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);
}
}
正如您从代码中看到的那样,我已经实现了onActivityResult,正如官方指南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>
清单文件中没有android:noHistory标志。
我在日志中找到的唯一错误
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)
我已经尝试过android 2.1,2.2和4.0.3并且遇到了同样的问题。
从Facebook sdk复制示例中的类也不起作用。
请提供任何可能的帮助。提前谢谢!
答案 0 :(得分:1)
Facebook Android SSO存在问题,它甚至在Platform Status中也是如此。
您可以通过此错误报告获取更多信息:https://developers.facebook.com/bugs/385350798163367